日期:2014-05-16 浏览次数:20364 次
<script type="text/javascript"> <!-- window.onbeforeunload = onbeforeunload_handler; window.onunload = onunload_handler; function onbeforeunload_handler(){ var warning="确认退出?"; return warning; } function onunload_handler(){ var warning="谢谢光临"; alert(warning); } // --> </script>
window.onbeforeunload = function() //author: meizz { var n = window.event.screenX - window.screenLeft; var b = n > document.documentElement.scrollWidth-20; if(b && window.event.clientY < 0 || window.event.altKey){ alert("是关闭而非刷新"); window.event.returnValue = ""; //这里可以放置你想做的操作代码 }else{ alert("是刷新而非关闭"); }