javascript判断页面是否是刷新还是关闭
<script>
function CloseOpen(event) {
if(event.clientX<=0 && event.clientY<0) {
alert("关闭");
}
else
{
alert("刷新或离开");
}
}
</script>
<body onunload="CloseOpen(event)">
<html>
<head>
<title>无忧脚本代码测试网页</title>
</head>
<body>
<script language=javascript>
windowonbeforeunload=function()
{
if(eventclientX>documentbodyclientWidth)
{
alert('浏览器关闭');
}
else
{
alert('浏览器刷新');
}
}
</script>
</body>
</html>