避免登录页面中的退格按钮 [英] avoid Backspace button in login page

查看:99
本文介绍了避免登录页面中的退格按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的登录页面中避免退格功能。

当我按Backspace时页面将重新加载。

解决方案

< pre lang =cs> // 试试这个。除了textareas和文本输入外,它将阻止退格


(document).keydown(function(e){
var preventKeyPress;
如果(e.keyCode == 8 ){
var d = e.srcElement || e.target;
switch (d.tagName.toUpperCase()){
case ' TEXTAREA'
preventKeyPress = d.readOnly || d.disabled;
break ;
case ' INPUT'
preventKeyPress = d.readOnly || d.disabled ||
(d.attr ibutes [ type]&&


。 inArray(d.attributes [ type]。 value .toLowerCase(),[ radio 复选框 提交 button])> ; = 0 );
break ;
case ' DIV'
preventKeyPress = d.readOnly || d.disabled || !(d.attributes [ contentEditable]&& d.attributes [ contentEditable]。 value == true);
break ;
默认
preventKeyPress = true ;
break ;
}
}
其他
preventKeyPress = false ;

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


I want to avoid backspace fuctionality in my Login page.
when I press Backspace the page would be reload.

解决方案

//Try this. It will prevent backspace except in the case of textareas and text inputs 


(document).keydown(function (e) { var preventKeyPress; if (e.keyCode == 8) { var d = e.srcElement || e.target; switch (d.tagName.toUpperCase()) { case 'TEXTAREA': preventKeyPress = d.readOnly || d.disabled; break; case 'INPUT': preventKeyPress = d.readOnly || d.disabled || (d.attributes["type"] &&


.inArray(d.attributes["type"].value.toLowerCase(), ["radio", "checkbox", "submit", "button"]) >= 0); break; case 'DIV': preventKeyPress = d.readOnly || d.disabled || !(d.attributes["contentEditable"] && d.attributes["contentEditable"].value == "true"); break; default: preventKeyPress = true; break; } } else preventKeyPress = false; if (preventKeyPress) e.preventDefault(); });


这篇关于避免登录页面中的退格按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆