Display an alert box:
alert("Hello! I am an alert box!!");
Click the button to display an alert box.
<!DOCTYPE html> <html> <body> <button onclick="myFunction()">Test</button> <script> function myFunction() {/*from ww w. j a va 2 s. c o m*/ alert("Hello! I am an alert box!"); } </script> </body> </html>
The alert()
method displays an alert box with a specified message and an OK button.
Syntax alert(message);
Parameter Values
Parameter | Type | Description |
---|---|---|
message | String | Optional. Set the text to display in the alert box, or an object converted into a string and displayed |
The alert()
method has No return value.