You can use JavaScript alert messages to display some information displaying blocks to the user interacting with your web pages. For example, onclick of button you can add a JavaScript alert message.

JavaScript Code Example

<input
    id="btnClick"
    type="button"
    value="click me"
    onclick="alert('Hello World');" />

You can use the above code to popup the alert message on the click event of the button

alert('Hello World');

Alert function also accepts the string values that can be displayed on any event triggered.

You can also display the multi line messages in the JavaScript alert messages. Just use back slash n (\n) to insert the new line in the string.

<input
    id="btnClick"
    type="button"
    value="click me"
    onclick="alert('Hello World!!!\nWhats Up?')" />

It will display the multi line message box alert. 

You can use function also to call the JavaScript alerts.

Continue to next tutorial: JavaScript Confirm Box to learn how to open the confirm message box using JavaScript.

Recent JavaScript Tutorials

Javascript FSO ShortPath property

Javascript FileSystemObject (FSO) provides a ShortPath property that can be accessed using the folder object or file object returned by the GetFolder or GetFile method.

Javascript FSO Path Property

Javascript FileSystemObject (FSO) provides the Path property that can be accessed through the file object or folder object returned by the GetFile or GelFolder method

Javascript FSO Type property

Javascript FileSystemObject (FSO) provides a Type property that can be accessed through file object or folder object returned by the GetFile or GetFolder method

Javascript FSO ShortName property

Javascript FileSystemObject (FSO) provides a ShortName property that can be accessed using the folder object or file object returned by the GetFolder or GetFile method.

Javascript FSO Name Property

Javascript FileSystemObject (FSO) provides a Name property that can be accessed using file object or folder object.