Function: alert('string')

alert() will cause an alert box to pop up. The string parameter (what's in the parentheses) will be the message. This function is used for sending messages to the user. If you need the user to respond then use prompt().

Examples:

The code:

<script type="text/javascript">
alert('This code get run when encountered in the script element below');
</script>

<p onclick="alert('hello there');">
blah blah blah....
</p>

<button onclick="alert('that tickles');">
Click me.
</button>

...as it appears on the Page:

blah blah blah....

See also: this, Nesting Quotes

Back to Knowledge Dump