onbeforedunload事件

来源:互联网 发布:合肥晨飞网络待遇 编辑:程序博客网 时间:2024/05/21 17:09
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="Content-Type" content="text/html">
<title>onbeforeload测试</title>
<script type="text/javascript">
      function checkLeave(ev){
          ev.returnValue="你确定离开当前的页面吗";
       }
    </script>
</head>
<body onbeforeunload="checkLeave(event)">
<p>好好学习</p>
</body>
</html>
<!-- onbeforeunload这个事件是在浏览器上关闭这个页面的时候会被调用
我们可以看到调用这个事件的时候对调用一个javaScript的函数,在刷新网页的
时候也会被调用
 -->
0 0
原创粉丝点击