87,922
社区成员
发帖
与我相关
我的任务
分享
var count=0;
function DoExit(){
if(count>0){
//退出执行
}
count++;
}
<html>
<body onunload="DoExit">
//.......
</body>
</html>
<html>
<script>function ext(){alert('ext')}</script>
<body onunload="ext()"></body>
</html>
function window.onbeforeunload()
{
if(event.clientX>document.body.clientWidth&&event.clientY<0||event.altKey||event.ctrlKey)
{
//判断event.altKey是为了Alt+F4关闭的情况;判断event.ctrlKey是为了Ctrl+W关闭的情况
//document.body.clientWidth不包括滚动条,而关闭按钮恰好在滚动条右侧。
window.event.returnValue="";
}
}