The JavaScript alert() is a method of the window object. It is a dialogue box that pops up and takes the focus away from the current window and forces the web browser to read the message. The user will have to click “OK” to proceed.
<script language=”javascript” type=”text/javascript”>
alert(’This is an alert message’);
</script>
The text placed inside the parenthesis is displayed on the pop-up box. If you want to show a string of literal text, enclose the text in quotes. To display variable values, enter the variable name without quotes. You can also combine variable values and text strings by using the + sign.
To write text on multiple lines in an alert box we use the new line escape character (\n).
If you mean to pops up a dialogue box asking for confirmation use confirm() instead.
Be First To Comment
Related Post
Leave Your Comments Below