PGDEL/DECP03/Unit3/20
Unit 3.3 Web application development tools & Technologies
JavaScript provides the capability to accept user inputs or display message to the users by using dialog boxes. Dialog boxes appear in a separate window.There are three types of the dialog boxes provided by JavaScript:
Dialog Box |
Syntax |
Example |
Alert Dialog Box
|
alert(“<Message>”) |
<HTML> <HEAD> <TITLE> Demonstrating Alert Dialog Box</TITLE> </HEAD> <BODY"> <SCRIPT type="text/javascript" > alert("Hello there"); </SCRIPT> </BODY> |
Prompt Dialog Box </HTML>Prompt Dialog BoxThe prompt dialog box allows interaction; it can used to customize any web page based on user input. |
prompt(“<Message>”,”<Value>”) |
<HTML> <HEAD> <TITLE> Demonstrating promptDialog Box </TITLE> </HEAD> <BODY"> <SCRIPT type="text/javascript" > var name = prompt("Enter your Name","Your Name"); document.write(" Welcome : "+name);</SCRIPT> </BODY> </HTML> |
Confirm Dialog Box:
|
confirm(“<Message>”); |
<HTML> <HEAD> <TITLE> Demonstrating Confirm Dialog Box </TITLE> </HEAD> <BODY"> <SCRIPT type="text/javascript" > var value=confirm("Sure to exit"); if(value) document.write(" Exit "); else document.write(" Continue "); </SCRIPT> </BODY> </HTML> |
Work in progress, expect frequent changes. Help and feedback is welcome. See discussion page. |