window.onbeforeunload = function(){ if(document.all){ //ie //右上角關閉按鈕 或 alt+F4 或 ctrl+w if(event.clientX > document.body.clientWidth || event.clientY < 0 ||event.altKey || event.ctrlKey){ return "關閉窗口"; }else{ return "刷新或跳轉"; } }else{ return "刷新、跳轉、關閉"; } }