After entering the content in the text box, you often need to press enter, focus to jump to the next text box, or trigger the button event to determine whether to press the carriage return is very simple:
The Code is as follows:
Function EnterPress (){
If (event. keyCode = 13 ){
...
}
}
The onkeypress of IE6 accepts the "carriage return event", while the onkeydown does not.
In IE8, onkeypress does not accept the "carriage return event", while onkeydown does.
... You don't have to worry about this. Write both of them.
The Code is as follows:
However, under FF, there will be a conflict. FF is onkeypress and onkeydown both accept the "carriage return event.
At the same time, to be compatible with FF, you need to write as follows:
The Code is as follows:
Function EnterPress (e) {// input the event
Var e = e | window. event;
If (e. keyCode = 13 ){
...
}
}
If you pass the parameter event to any event and do not pass the parameter, you can run FF only once:
The Code is as follows:
&
In summary, compatible with IE and FF:
The Code is as follows:
Script
Function EnterPress (e) {// input the event
Var e = e | window. event;
If (e. keyCode = 13 ){
Document. getElementById ("txtAdd"). focus ();
}
}
Script
-- By: Bubble fantasies