`

(window.onunload)只有点击浏览器右上角关闭按钮才执行

 
阅读更多

<html>
<head>
<script type="text/javascript">
//
window.onunload = function()
{
if ((function(){
var a = 0;
var b = 0;
if(parseInt(navigator.appVersion) > 3)
{
if(navigator.appName == "Netscape")
{
a = window.innerWidth;
b = window.innerHeight;
}
if(navigator.appName.indexOf("Microsoft") != - 1)
{
a = top.window.document.body.offsetWidth;
b = top.window.document.body.offsetHeight;
}
}
return(event.clientY < 0 && event.screenX > (a - 25));
}
)()){
//关闭 浏览器窗口时代码

alert("window close");
}
}
</script>
<body>
</body>
</html>

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics