javascript 如何判断关闭窗口

<script language="javascript">
window.onbeforeunload = function()
{
var n = window.event.screenX - window.screenLeft;
var b = n > document.documentElement.scrollWidth-20;
if(b && window.event.clientY < 0 || window.event.altKey)
{
 postTime();
 window.event.returnValue = " 建议您先停止视频再关闭窗口";
}
}
</script> 

你可能感兴趣的:(JavaScript)