在<body onbeforeunload="alert('提示')"></body>时提示<body>中没有onbeforeunload事件,写onunload可以但是onbeforeunload提示没有这个元素。提示错误:Validation(XHTML1.0 Transitional):Attribute 'onbeforeunload' is not a valid attribute of element'body'.
解决方案 »
- 关于JS 关键词高亮显示的代码,如何显示两位数字
- 请帮看下这段js
- 关于javascript与json
- 利用JavaScript取消当前页面的链接
- windows.open在IE7中的标题能否去掉地址问题
- (难)confirm和alert消息框
- 给div命名的问题!
- 这个程序中每个变量在使用前为什么都不要用var声明一下
- 同一IP每隔10分钟才能发布信息
- 我在<script>中用window.location.href="error.htm";为什么不能转向另一个页面?要怎么转?
- 麻烦帮我解释一下这小段代码,谢谢了
- document.onclick = function(){}如何获得event啊
<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>
</html>
onbeforeunload 部分浏览器支持
至于浏览器我用的是IE9