您的位置:首页 > Web前端 > JavaScript

js判断页面是刷新还是关闭

2010-08-16 13:42 567 查看
<mce:script type="text/javascript"><!--
function close(evt) //author: sunlei
{
var isIE=document.all?true:false;
evt = evt ? evt :(window.event ? window.event : null);
if(isIE){//IE浏览器
var n = evt.screenX - window.screenLeft;
var b = n > document.documentElement.scrollWidth-20;
if(b && evt.clientY<0 || evt.altKey){
//alert("是关闭而非刷新");
window.location.href="../include/logout.php";
}
else{
//alert("是刷新而非关闭");
return false;
}
}
else{//火狐浏览器
if(document.documentElement.scrollWidth!=0)
{
//alert("是刷新而非关闭");
//window.location.href="report_list.php?ss=1";
return false;

}
else{
alert("是关闭而非刷新");
//window.location.href="repost_list.php?ss=0";
//alert("bbbbbbb");
}
}
}
// --></mce:script>
<BODY onunload="close(event);">


转自:http://quanwei0924.blog.163.com/blog/static/513801982010465244815/
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息