Alert Method In

 

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.

 

FORMAT

alert("String of plain text"); alert(expression);

 

Example:

 

Var a=5; Var b=7; alert(a + b); //show 12 alert("Phone number is incorrect"); //show phone number is incorrect

HTML Example

 

alert("Tutorial Published By, "); alert("http://www.coolajax.net"); alert("This is a cool message from http://www.coolajax.net!");

EXPLANATION

The tag. JavaScript does not understand HTML tags unless they are embedded in a string.

The () 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 () 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

nbsp;

Demos:

http://demos.coolajax.net/javascripts/alert/

 

Download:

http://demos.coolajax.net/javascripts/alert/index.zip



Like our site? Be a member of Coolajax fan page to get daily posts updates!

recommended-tutorial You May Like This Posts!

» Alert Method In Javascript

» Nice JavaScript Techniques Using for awesome CSS Styling

» Reserved keywords

» Creating a javascript Block

  tuts_view Total Read: 693
blog comments powered by Disqus

Topics

Coolajax Fans

coolajax fan page on Facebook