JavaScript & HTML Tips
 Home
Feature highlight: Popup Dialogs to Interact with Users
 Credit: Imagenation


Description
Using browser dialogs to interact with users and forms.

Background
Interacting with users on Web pages is done 3 ways:
1) through 3 types of popup dialogs which we will illustrae just below;
2) through HTML Forms which again we use below but only for demo purposes;
3) through third party forms and embedded scripts using <embed> or proprietary tags.


Key features and JavaScript elements
The buttons below will trigger use of the following JavaScript popup dialog routines:
1)Greetings will demonstrate the alert() dialog;
2)Fill BlackBoard will demonstrate the prompt() dialog;
3)Clear BlackBoard will demonstrate the confirm() dialog;


alert(" Greetings from BadMan Bart");
Alerts are used to send a simple popup message or warning to the user. Since developers do not have control over the warning icon and the popup title - some try to avoid this message popup because it has connations of something going wrong. But it is simple and easy to use.


num = prompt("Fill in blackboard how manytimes ?","20")
Prompts allow users to get a response from the user. The first parameter is what the user will be prompted for; the second parameter is the default value. Note prompt returns a value stored in num in this case. But if the user cancels the prompt the whole routine is abandoned.


confirm("Are you sure you want to clear the Blackboard");
Confirms allow the developer to get a yes/no response from the user on what to do next. Confirm returns True if the user clicks the OK button and returns False if the user clicks the Cancel button. Simple but effective.

Use View | Source to see all the details on how Bart did his mischief on this page.

 
Top of Page  Tutorials Home  JavaScript References  JavaScript Books