我们想在用户关闭浏览器之前抛出特定的消息.是否有一种机制适用于所有主流浏览器(如IE,Firefox,Chrome,Opera)
window.onbeforeunload = function (e) {
var e = e || window.event;
if (has_message_to_throw) {
// For IE and Firefox
if (e) {
e.returnValue = 'Specific message';
}
// For Safari
return 'Specific message';
}
};
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1313 次 |
| 最近记录: |