Alert Method In Javascript

Alert Method In Javascript

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.

How to write basic JavaScript alert function?

how to write basic javascrpt alert function?

JavaScript alert Example:

javascript alert example

EXPLANATION

Thetag. 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.

javascript alert message

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!

Share It

Related Posts