When the keyboard presses the Backspace key (Backspace)
1. Prohibit the browser from automatically backing
2. But it does not affect the fallback operation of password, single-line text, multi-line text input box, etc.
<script type="text/javascript"> //Train the Backspace password or single-line or multi-line text boxes for processing keyboard events except function banBackSpace(e){ var ev = e || window.event;//Get the event object var obj = ev.target || ev.srcElement;//Get the event source var t = obj.type || obj.getAttribute('type');//Get the event source type//Get the event type as a judgment condition var vReadOnly = obj.getAttribute('readonly'); var vEnabled = obj.getAttribute('enabled'); //Troubleshoot null value vReadOnly = (vReadOnly == null) ? false : vReadOnly; vEnabled = (vEnabled == null) ? true : vEnabled; //When the Backspace key is typing, the event source type is password or single-line or multi-line text, //If the readonly attribute is true or the enabled attribute is false, the backspace key will be invalid var flag1=(ev.keyCode == 8 && (t=="password" || t=="text" || t=="textarea") && (vReadOnly==true || vEnabled!=true))?true:false; //When the Backspace key is typing, if the event source type is not a password or single-line or multiple-line text, the backspace key will be invalid var flag2=(ev.keyCode == 8 && t != "password" && t != "text" && t != "textarea") ?true:false; //Judge if(flag2){ return false; } if(flag1){ return false; } } //Forbid the back key to act on Firefox and Opera document.onkeypress=banBackSpace; //Forbid the back key to act on IE and Chrome document.onkeydown=banBackSpace; </script>The above is the situation of preventing clicking Backspace web pages from backing in the JavaWeb page that the editor introduced to you. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to everyone in time. Thank you very much for your support to Wulin.com website!