黑马程序员技术交流社区
标题:
onbeforeunload 事件DOm
[打印本页]
作者:
胡元江
时间:
2013-2-27 11:41
标题:
onbeforeunload 事件DOm
onbeforeunload="window.event.returnValue('确定要离开此页么')"这个事件写在哪里一般。在body中还有几个元素中都说不是他的有效元素。
作者:
彭思
时间:
2013-3-2 00:00
onbeforeunload是在网页准备离开或者关闭后触发,针对的是整个页面,所以应该是在body中。
作者:
岳珅
时间:
2013-3-2 00:21
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>onbeforeunload测试</title>
<script>
function checkLeave(){
event.returnValue="确定离开当前页面吗?";
}
</script>
</head>
<body onbeforeunload="checkLeave()">
</body>
复制代码
看了你就明白,在body中的~
欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/)
黑马程序员IT技术论坛 X3.2