监控页面刷新

以前在CSDN上看见的。来源已忘记。在此做记录备用:

<mce:script language="javascript"><!-- var _s="close"; //window.onunload = function(){ //if(_s=="fresh") //alert('刷新'); //else // alert('关闭'); //} window.onbeforeunload = function(){ _s="fresh"; } 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)) { window.event.returnValue = false; } } // --></mce:script>

你可能感兴趣的:(JavaScript,function)