When the keyboard knocks down the back key (Backspace)
1, prevent the browser automatically back
2, but does not affect the password, single line text, multiline text input box, such as the fallback operation
<script type= "Text/javascript" >//Handling keyboard events prohibit back key (Backspace) password or single line, multiline text box exception function Banbackspace (e) {var ev = e | | window.event;//get Event object var obj = Ev.target | | ev.srcelement;//get event source var t = Obj.type | |
Obj.getattribute (' type '); Get event Source Type//Get the event type as a condition of judgment var vreadonly = Obj.getattribute (' readonly ');
var venabled = Obj.getattribute (' enabled '); Handling Null value condition Vreadonly = (Vreadonly = = null)?
False:vreadonly; venabled = (venabled = null)?
true:venabled; When the BACKSPACE key is hit, the event source type is a password or single line, multiline text,//And the ReadOnly property is True or the Enabled property is False, and the BACKSPACE key fails var flag1= (Ev.keycode = = 8 &&
(t== "Password" | | t== "TEXT" | | t== "TEXTAREA") && (Vreadonly==true | | venabled!=true))? True:false; The BACKSPACE key fails var flag2= (Ev.keycode = 8 && t!= "password" && t!= "text" backspace when the event source type is not a password or a single line, multi-line text, when the key is tapped &A
mp;& T!= "textarea")? True:false;
Judge if (Flag2) {return false;
} if (Flag1) {return false; }//No back key acts on Firefox, Opera Document.onkeYpress=banbackspace;
Prohibit the back key role in IE, Chrome document.onkeydown=banbackspace; </script>
The above is a small set to introduce the Javaweb page to prevent click Backspace page back, I hope to help you, if you have any questions please give me a message, small series will promptly reply to everyone. Here also thank you very much for the cloud Habitat Community website support!