Make your own free website on

Chapter 3: JavaScript Dialog Box


3.1 Dialog box

 Dialog box that pop up in a webpage will enhance interactivity of the webpage. A dialog normally carries a message or question that required some form of action from the user, either clicking a button or pressing a key on the keyboard .The syntax  is very simple, you just need to use the alert method. The structure is as follows:



windows.alert("Welcome to JavaScript Tutorial");



Adding this Script will allow the user too see a popup dialog box that displays the message "welcome to JavaScript Tutorial" as you have seen when you come to this visit this page, as I have put this line in this webpage. Refresh this page will let you see the dialog box again as shown in the diagram below:

You can customized the format of the output using a backslash \ and "n". Lets change the line windows.alert("Welcome to JavaScript Tutorial") to

window.alert"welcome to\nJavaScript\nTutorial"). The output will be displayed in three lines now, as shown below:

If you put the two scripts together, you will see two dialog boxes appear successively, after you click the first one, the second one will appear.






<Previous Chapter> [Back to HTMLTutorial] <Next Chapter>