下面是Js片段在IE9,Firebox 10.0.2 中测试过 :
实现代码如下:

$(document).keydown(function (e) {
var doPrevent;
if (e.keyCode == 8) {
var d = e.srcElement || e.target;
if (d.tagName.toUpperCase() == 'INPUT' || d.tagName.toUpperCase() == 'TEXTAREA') {
doPrevent = d.readOnly || d.disabled;
}
else
doPrevent = true;
}
else
doPrevent = false;

if (doPrevent)
e.preventDefault();
});

关于如何确定Backspace键的代码可以通过这里
 希望对您Web开发有帮助。

以上就是【JQuery防止退格键网页后退的实现代码】的全部内容了,欢迎留言评论进行交流!

赞(0) 踩(0)
发表我的评论

最新评论

  1. 暂无评论