<!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 οnbefοreunlοad="checkLeave(event)">
<p>好好学习</p>
</body>
</html>
<!-- onbeforeunload这个事件是在浏览器上关闭这个页面的时候会被调用
我们可以看到调用这个事件的时候对调用一个javaScript的函数,在刷新网页的
时候也会被调用
-->
<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 οnbefοreunlοad="checkLeave(event)">
<p>好好学习</p>
</body>
</html>
<!-- onbeforeunload这个事件是在浏览器上关闭这个页面的时候会被调用
我们可以看到调用这个事件的时候对调用一个javaScript的函数,在刷新网页的
时候也会被调用
-->