日期:2014-05-16 浏览次数:20340 次
方案一:
<html> <head> <script language="javascript"> 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 = ""; //这里可以放置你想做的操作代码 } } </script> </head> </html>
?
?
方案二:
<html> <head> <title>判断是刷新还是关闭</title> </head> <script> function CloseOpen(event) { if(event.clientX<=0 && event.clientY<0) { alert("关闭"); } else { alert("刷新或离开"); } } </script> <body onunload="CloseOpen(event)"> </body> </html>
?