- The alert box can be used, when developers would like to warn the user about something. For example "the following page contains uncomfortable materials not suitable for those under the age of 18. Following script gives the idea of alert box.
Listing 1: Script of Alert Box
Figure 1: Above figure is an output of alert script which tell the user about further processing.
- When developer wants the user to input a value before entering a specific webpage prompt box is used.In the case of appearance of prompt box, the user will either have to click "OK" to proceed after entering an input value or "Cancel”. When user clicks "OK" the box returns the input value and when he clicks "Cancel" the box returns null. Following script compile the idea of prompt box Listing 2: Script for Prompt Box
- A confirm box is used when developer wants the user to accept something. When a confirm box display on web page, the user will have to click either "OK” to proceed, "Cancel” if they decide not to proceed.If the user clicks "OK", the box returns true. If the user clicks "Cancel", the box returns false.
- Sometimes the actions need to be confirmed by the users so as to avoid later blame on the website, hence, confirm boxes are used to. The actions for example, may be to confirm an order submission or a link clicked will take users to another website, require confirmation. Following script will clear the procedure.
Figure 2: Above output is script of prompt box if user will enter to the page he will have to enter the details what have been asked.
Figure 3: Above output is output of prompt box. The first output is asking for username and second one is showing the alert for the same.
Listing 3: Script of confirmation box
Figure 4: the first output ask the user that user wants to navigate to Mrbool site and once user click on “ok” button.
Figure 5: If user clicks on cancel button, the script thanks the user and asks for visiting the site in future.
Tutorial explained all three types of pop up boxes and I hope the article is useful for you. If you have any query please do comment @mrbool site.