更新时间:2023-12-04 14:06:29
与Ghommey的答案类似,但这也支持旧版本的IE和Firefox。
Similar to Ghommey's answer, but this also supports old versions of IE and Firefox.
window.onbeforeunload = function (e) {
var message = "Your confirmation message goes here.",
e = e || window.event;
// For IE and Firefox
if (e) {
e.returnValue = message;
}
// For Safari
return message;
};