js 捕获浏览器关闭或者刷新页面给出提示

window.onbeforeunload = function() {

return " ";

}
document.onkeydown = function() {
if ((window.event.keyCode == 116) || //屏蔽 F5 
(window.event.keyCode == 122) || //屏蔽 F11 
(window.event.shiftKey && window.event.keyCode == 121) //shift+F10 
) {
window.event.keyCode = 0;
window.event.returnValue = false;
}
if ((window.event.altKey) && (window.event.keyCode == 115)) { //屏蔽Alt+F4 
window.showModelessDialog("about:blank", "", "dialogWidth:1px;dialogheight:1px");
return false;
}
}

js 捕获浏览器关闭或者刷新页面给出提示,布布扣,bubuko.com

js 捕获浏览器关闭或者刷新页面给出提示

上一篇:js Dom


下一篇:基于jQuery编写的页面跳转简单的小插件