Page 352 - Webapplication11_C11_Flipbook
P. 352
Lab Assignment ‘n Activity #Subject Enrichment
Give the output of the following code:
1. str1 = "She dropped the glass";
document.write(str1.substring(3,14))
2. document.write (parseFloat("I am 18 years old"))
3. document.write(eval("7" + "5"))
4. ans=eval("78" – "65");
document.write(ans)
5. document.write(Number("12 67"))
6. document.write(Boolean(34>68))
Notes
Python has piqued the interest of 30% of developers who haven’t worked with it before. Second on the list is
JavaScript. 18.5 percent of developers expressed an interest in learning and developing in the field.
[Stack Overflow Annual Survey 2020]
4.20 INTERACTING WITH USER—DIALOG BOXES
You already know that a dynamic website requires user involvement to function. A user inputs data into a website
using a variety of methods, such as a keyboard or a mouse, and receives a response. The simplest way for a user to
interact with a website is through dialog boxes. The user can be given information or asked to input a value that the
application demands.
We’ve already seen document object methods for displaying data on a web page. Similarly, window is an object with its
own set of methods. Dialog boxes are used by the window object to interface with the user. Three methods are used to
build dialogue boxes: alert( ), prompt( ), and confirm( ). These methods do not need the presence of a window object
by default. Since the window object is a top-level object, it is not necessary to mention it when the method is invoked.
The alert( ) Method
Ð ÐThis dialog box is used to show the user a warning message. When a user enters inaccurate information, the
developer will utilise an alert box to show the user a warning or error.
Ð ÐIt has a little triangular icon, a user-customized message, and an OK button.
Ð ÐWhen this dialog box displays, all execution is halted and the user is asked to press the OK button.
Ð ÐIt can also be used for debugging to see if the program is running in the correct order by providing output.
Ð ÐThe appearance of the alert() box varies from browser to browser.
Ð ÐIt can display a valid expression, string, or variable value that is supplied to the alert( ) method as an argument.
Example:
<HTML>
<HEAD><TITLE>Dialog Box </TITLE></HEAD>
<BODY>
<H1> Learning JavaScript Alert </H1>
<script type="text/javascript">
alert(10+5*3)
350 Touchpad Web Applications-XI

