<script type="text/javascript">
window.onbeforeunload = function() {
var n = window.event.screenX - window.screenLeft;
var b = n > document.documentElement.scrollWidth - 20;
//用戶點擊瀏覽器右上角關閉按鈕
if (b && window.event.clientY < 0 || event.clientX > document.body.clientWidth && event.clientY < 0 || event.altKey) {
window.event.returnValue = "確定要退出本頁嗎?";
window.location.href = "";
}
//用戶點擊任務欄,右鍵關閉
else if (event.clientY > document.body.clientHeight || event.altKey) {
window.event.returnValue = "確定要退出本頁嗎?";
}
else//其他情況爲刷新
{
alert("你在刷新");
}
}
</script>