//屏蔽系统里的backspace键
$(document).on("keydown", function () {
if (event.keyCode == 8) {
if (document.activeElement.type == "text") {
if (document.activeElement.readOnly == false)
return true;
}
return false;
}
});
//离开当前页面(比如页面跳转)所触发的事件函数
window.onbeforeunload = function (e) {
if (GObj == null || GObj.length < 1 || $(parent.document).find('.ui-dialog').length < 1)
return;
return "";
};
//该事件函数紧跟在onbeforeunload后面执行(当然是要在onbeforeunload有返回值的情况下才执行,否则不执行)
$(window).unload(function () {
if (GObj !== null && GObj.length > 0)
GObj.dialog("close");
return;
});
//设置一个全局变量存储模态对话框,以便后续如果点击浏览器的后退键时获取对话框对象进行处理
var GObj = null;
js屏蔽backspace键/点击浏览器后退按钮提示
最新推荐文章于 2020-12-24 20:04:49 发布