Window alert()
Example
Display an alert box:
alert("Hello! I am an alert box!!");
Try it Yourself »
More examples below.
Definition and Usage
The alert()
method displays an alert box with a message and an OK button.
The alert()
method is used when you want information to come through to the user.
Note
The alert box takes the focus away from the current window, and forces the user to read the message.
Do not overuse this method. It prevents the user from accessing other parts of the page until the alert box is closed.
See Also:
Syntax
alert(message)
Parameters
Parameter | Description |
message | Optional. The text to display in the alert box. |
Return Value
NONE |
More Examples
Browser Support
alert()
is supported in all browsers:
Chrome | IE | Edge | Firefox | Safari | Opera |
Yes | Yes | Yes | Yes | Yes | Yes |