We can send output to the browser by using the alert() method. The alert() method creates a little independent box—called a dialog box—which contains a small triangle with an exclamation point.
A user-customized message is placed after the triangle, and beneath it, an OK button. When the dialog box pops up, all execution is stopped until the user presses the OK button in the pop-up box. The exact appearance of this dialog box may differ slightly on different browsers, but its functionality is the same.
The message for the alert dialog box is a string of text (or a valid expression) enclosed in double quotes, and sent as a single argument to the alert() method. HTML tags are not rendered within the message string but you can use the escape sequences, \n and \t.


EXPLANATION
The tag. JavaScript does not understand HTML tags unless they are embedded in a string. The alert method sends its output to the browser. The HTML font tag is embedded in the string and will be sent to the browser for rendering. This is another alert method that outputs its text followed by a newline
The alert() method will produce a little dialog box, independent of the current document, and all processing will be stopped until the user presses the OK button. This little box can be moved around the screen with your mouse.
A closing tag ends the JavaScript program. The output is shown in figure.

Demos:
http://demos.coolajax.net/javascripts/alert/
Download:
http://demos.coolajax.net/javascripts/alert/index.zip
Was this information useful? What other tips would you like to read about in the future? Share your comments, feedback and experiences with us by commenting below!
Like our site? Be a member of Coolajax fan page to get daily posts updates!
Tags:
alert method, alert JavaScript, JavaScript tutorials, dialog box, alert JavaScript demos, alert code, download alert JavaScript
Total Read: 786 Topics