ArticleDirectory
There are multiple input fields in form. You can navigate through tabs in these input fields. You need to press the Enter key to obtain the same effect as the tab.
Convert the Enter key to the tab key
Can be implemented in IE,CodeThe following HTML code
-
- <Html Xmlns=Http://www.w3.org/1999/xhtml">
-
- <Head>
- <Meta HTTP-equiv="Content-Type" Content="Text/html; charset = UTF-8">
-
- <Title>Untitled document</Title>
-
- <Script Type="Text/JavaScript">
-
- Function entertotab (event ){
- VaRE=Event? Event: window. Event
-
- If (E. keycode= 13 ){
-
- E. keycode=9;
-
- }
-
- }
-
- </Script>
-
- </Head>
-
-
- <Body>
- <Form>
-
- <Input ID="Input1" Type="Text">
-
- <Input ID="Input2" Type="Text">
- <Input ID="Input3" Type="Text">
-
- <Input ID="Input4" Type="Text">
-
- </Form>
-
- </Body>
-
- </Html>
<HTML xmlns = "http://www.w3.org/1999/xhtml">
However, the keycode of the event in Firefox is read-only and cannot be modified. I do not know how to implement this function in Firefox.
Answer
- FunctionEntertotab (OBJ, event ){
- VaRE = event? Event: window. Event
- If(E. keycode = 13 ){
- OBJ. nextsibling. Focus ();
- Return False;
- }
- }
Function entertotab (OBJ, event) {var E = event? Event: window. eventif (E. keycode = 13) {obj. nextsibling. Focus (); Return false ;}}
The function transmits another parameter, that is, this of the current Dom. The principle is that the current input of the entry, so that the mouse focus is obtained to the next input box.