JavaScript Alert

From JumbaWiki

Jump to: navigation, search

When testing your script, an alert is a good tool to test variable values or to see if parts of code are working as you want them to. This is the standard output for JavaScript.

Note: These scripts should all be within a script tag:

   <script type="text/javascript" language="Javascript">
       //YOUR CODE HERE
   </script>

Standard alert

   alert("Hello World!");

Alternative alerts

Here are some alternatives with confirmation and prompts.

 confirm("Are you sure?");

Returns the text in brackets along with an Ok and Cancel button.

 prompt("What's your name?", "(optional)");

Returns the text as a question with a space for the user to type input. An ok and Cancel button are supplied.

See also

Personal tools
Australian Photographs | Unique Views of Reality | Daedalus