In JavaScript, you can use the alert() method of the Window object to implement an alert box. The function of this method is to pop up a warning box with a specified message and an "OK" button; the syntax "alert( message)".
The operating environment of this tutorial: windows7 system, javascript version 1.8.5, Dell G3 computer.
In javascript, if we want to pop up a warning box, we can use the alert() method.
alert() is a method of the Window object, which is used to display an alert box with a specified message and an OK button.
But the window.alert() method can use the alert() method directly without the window object. Specific syntax format:
alert(message)
Parameter description:
message: Specify the plain text (not HTML text) to be displayed in the dialog box that pops up on the window )
Sample code:
<!DOCTYPE html> <html> <head> <script type="text/javascript"> function display_alert() { alert("我是一个警告框!") } </script> </head> <body> <input type="button" onclick="display_alert()" value="点击按钮,弹出警告框" /> </body> </html>
Rendering:
We click the button below
A warning box will pop up
[Recommended learning: javascript advanced tutorial]
The above is the detailed content of How to implement warning box in javascript. For more information, please follow other related articles on the PHP Chinese website!