Home  >  Article  >  Web Front-end  >  How to implement warning box in javascript

How to implement warning box in javascript

青灯夜游
青灯夜游Original
2021-10-18 16:05:079351browse

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)".

How to implement warning box in javascript

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

How to implement warning box in javascript

A warning box will pop up

How to implement warning box in javascript

[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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn