Home > Web Front-end > JS Tutorial > body text

What does javascript alert mean?

青灯夜游
Release: 2022-12-30 11:13:28
Original
16752 people have browsed it

alert means "warning" in English. In JavaScript, alert() refers to a pop-up warning box; the alert() method can display a warning box with a specified message and an "OK" button ;After the user has finished reading the displayed information, they can simply click the "OK" button to close the dialog box.

What does javascript alert mean?

The operating environment of this tutorial: Windows 7 system, ECMAScript version 5, Dell G3 computer.

What does javascript alert mean?

javascript alert()

#alert() method is used to display a message with a specified message and an "OK" button Warning box.

alert() method simply and clearly displays the text information in the () brackets in the dialog box. The dialog box contains a "Confirm" button. After the user reads the displayed information, he only Click this button to close the dialog box. Let's look at an example of using the alert() method. The code is as follows:

<html>
<head>
<title>编写html页面</title>
<script language= "javascript" > //JavaScript脚本标注
alert( "上联:山石岩下古木枯" ); //在页面上弹出上联
alert( "下联:白水泉边少女妙" ); //在页面上弹出下联
</script>
</head>
</html>
Copy after login

Execute the above small example, a dialog box will pop up on the page and display the sentence "Shanglian: Ancient trees are dead under the rocks." As shown below:

What does javascript alert mean?

Then, click the "Confirm" button and then the second dialog box will be displayed and "The girl beside the white water spring is wonderful!", the effect is as follows;

What does javascript alert mean?

Let’s analyze this small example:

a. Call the alert() method twice in the <script> script block;<br/></script>

b. A piece of text information is added in each alert() bracket. The page shown below appears when running. When you click the "OK" button on the page with the mouse, the first page appears. Click the "OK" button on the second page to close the dialog box on the page. Note: The two dialog boxes are displayed separately, rather than one covering the other. This is because js actually executes the first alert() and waits until the user clicks the "Confirm" button before executing the second alert(). .

alert() is a method of the js window object. When called, it can be written as window.alert() or alert(). Its function is to generate a dialog box with a confirmation button and brackets displayed above. For more information on computer programming, please visit:

Programming Teaching

! !

The above is the detailed content of What does javascript alert mean?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template