1 window.onbeforeunload = function (e) { 2 e = e || window.event; 3 // For IE and Firefox prior to version 4 4 if (e) { 5 e.returnValue = '确定退出吗?'; 6 } 7 8 // For Safari 9 return '确定退出吗?'; 10 }