[英]how to stop backspace from redirecting to a blank page?
I am working on a JSP page and whenever i place the cursor on a disabled textbox and hit backspace on my keyboard i get a blank screen.我正在处理 JSP 页面,每当我将光标放在禁用的文本框上并按键盘上的退格键时,我都会得到一个空白屏幕。 How do I solve this problem?
我该如何解决这个问题?
I have already tried using the "readonly" attribute but the problem still persists.我已经尝试使用“只读”属性,但问题仍然存在。
You can control this behavior by calling event.preventDefault();
你可以通过调用
event.preventDefault();
来控制这种行为event.preventDefault();
in-case of back button pressed using keydown
event of the readOnly
fields as following:如果使用
readOnly
字段的keydown
事件按下后退按钮,如下所示:
HTML: HTML:
<input type="text" id="search" readOnly />
jQuery: jQuery:
jQuery('#search').bind('keydown', function(event){
var keycode = (event.keyCode ? event.keyCode : event.which);
if(keycode == '8')
event.preventDefault();
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.