window.onbeforeunload方法在IE内核浏览器是有效的,但是在google浏览器中并不兼容,请教给位怎么在google浏览器中兼容window.onbeforeunload方法
采纳的答案
window.onbeforeunload = function (e) {
e = e || window.event;
// For IE and Firefox prior to version 4
if (e) {
e.returnValue = ‘确定退出吗?‘;
}
// For Safari
return ‘确定退出吗?‘;
};
时间: 2024-10-05 00:03:29