Skip to main content

Language-Specific Built-in Functions

To help with script programming, the JavaScript language provides many functions already built-in the browser. These functions are readily available and you can use them as you see fit.

A message box is a rectangular window used to display a message to the user. To display a message box, use the alert() function. This function is used to display a message box that is equipped with a button with a caption as OK. As long as the message box displays, the user must close it in order to return to the browser, meaning the browser is not accessible while the message box is available.

The syntax of the alert() function is:

 
alert(WhatToDisplay);
 

The argument of this function can be a number.

For example, to display the number 12 when the user clicks a button, you can use code as follows:

 
 <Script Language="JavaScript">
function displayNumber()
{
  alert(12);
}
</Script>
 

Next: Message Box with Options