捕获window.close()事件写自己的方法
<script language="JavaScript">
<!--
function myexit()
{
// do anything
return "测试关闭事件页面";
}
//-->
</script>
</head>
<body bgcolor="#FFFFFF" text="#000000" onbeforeunload="event.returnValue=myexit()">
<!--
function myexit()
{
// do anything
return "测试关闭事件页面";
}
//-->
</script>
</head>
<body bgcolor="#FFFFFF" text="#000000" onbeforeunload="event.returnValue=myexit()">
刷新时不触发网页退出事件
<script language=javascript>
function window.onbeforeunload()
{
if(event.clientX>document.body.clientWidth&&event.clientY<0||event.altKey)
{
window.event.returnValue="确定要退出本页吗?";
}
}
</script>
<script language=javascript>
function window.onbeforeunload()
{
if(event.clientX>document.body.clientWidth&&event.clientY<0||event.altKey)
{
window.event.returnValue="确定要退出本页吗?";
}
}
</script>