警报的功能是什么?

时间:2016-03-14 23:25:45

标签: javascript html

我已经在javascript上研究了一些代码..顺便说一句我是新手:)。这是一个问题:什么是“警报”的功能?

<html> 
<body>   
<h1>Counting rabbits</h1>   
<script>     
for(var i=1; i<=3; i++) 
{       alert("Rabbit "+i+" out of the hat!")     }   
</script>    
<h1>...Finished counting</h1>

</body>
</html>

2 个答案:

答案 0 :(得分:2)

让我谷歌那个:https://developer.mozilla.org/en-US/docs/Web/API/Window/alert

Alert是全局窗口对象上的一种方法,它提供对本机通知实用程序的访问。

window.alert("Hello world!");

它可以用于直接用户通知(如果你没有实现“更好”的东西),或者作为console.log的笨拙替代品。

答案 1 :(得分:0)

alert功能的功能是显示一个警告框,如下所示: enter image description here

通常最好说window.alert而不是alert