没想到啊

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
</head>
<body>
检测浏览器关闭,同时屏蔽F5
listen browser colse event and disable F5,
</body>
</html>
<script type="text/javascript">
<!--
window.onbeforeunload
= onbeforeunload_handler;
window.onunload
= onunload_handler;
document.onkeydown
= disableF5;
function onbeforeunload_handler(){
if(1==1){
var warning="Close this window?";
return warning;
}

}
function onunload_handler(){


}
function disableF5(e)
{

if (!e)
{
var e = window.event;
}
var keycode = e.keyCode;
if (e.which)
keycode
= e.which;

var src = e.srcElement;
if (e.target)
{
src
= e.target;
}
// 116 = F5
if (116== keycode)
{
// Firefox and other non IE browsers
if (e.preventDefault)
{
e.preventDefault();
e.stopPropagation();
}
// Internet Explorer
elseif (e.keyCode)
{
e.keyCode
=0;
e.returnValue
=false;
e.cancelBubble
=true;
}

returnfalse;
}
}

-->
</script>

 

IE6 不行 :(

posted on 2011-11-09 17:16  没想到啊  阅读(697)  评论(1编辑  收藏  举报