Dieser Artikel beschreibt die Methode des JS -Drücken -Eingabetaste, um Anmeldung zu erreichen. Diese Funktion hat eine breite Palette von praktischem Wert. Teilen Sie es für Ihre Referenz. Die spezifischen Methoden sind wie folgt:
Methode 1:
<html xmlns = "http://www.w3.org/1999/xhtml"> <head> <title> Überprüfen Sie die Punktzahl </title> <script Language = "JavaScript"> Funktion keylogin () {if (Ereignis.KeeCode == 13). // Anmeldenereignis Aufrufen Sie die Anmeldetaste} </script> </head> <body Onkeydown = "Keylogin ();"> <Eingabe id = "input1" value = "login" type = "button" onclick = "alert ('Aufruf erfolgreich!')"> </Body> </html>>Methode 2:
<Script> Funktion keyDown () {if (Ereignis.KeyCode == 13) {Ereignis.ReturnValue = false; event.cancel = true; Form1.BTNSUBMIT.CLICK (); }} </script>Wie man verwendet:
<Formular name = "Form1" methode = ""> Benutzername: <Eingabe type = text size = 20 maxLength = 8 OnKeydown = KeyDown ()> Kennwort: <Eingabe type = Passwort size = 20 maxLength = 8 OnKeydown = KeyDown ()> <Eingabe type = "subly" name = "btnsubmit" value = "subjekt" /> < /< /Form> Form> Form> Form> Form> Form> Form> Form> Form> Form> Form> Form> Form> Form> Form> Form> Form> Form> Form> Form> Form> Form> Form> Form> Form> Form> Form> Form> Form> Form> Form> Form> Form> Form> Form> Form> Form> Form> Form> Form> Form> Form> Form> Form> Form> Subjekt>
Methode 3:
Jede Website -Seite verfügt über eine Anmeldeschnittstelle. Nach dem Eingeben des Benutzernamens und des Kennworts müssen Sie oft auf eine Schaltfläche oder einen Link klicken, der sich mit der Maus anmelden. Auf diese Weise können Sie die Website eingeben, um das zu tun, was Sie gerne tun.
Manchmal frage ich mich, ob ich einfach eingeben kann, was ich eingeben soll, und dann einfach in den Wagen eingeben und die Anmeldefunktion ausführen? Die Lösung lautet wie folgt:
Ss.html Seitencode:
<html> <kopf> <titels> </title> <meta http-äquiv = "content-type" content = "text/html; charset = gb2312"> <link rel = "styleSheet" href = "css/text.css" type = "text/css"> </head> </head> </head> </head> </head> </head> </head> </head> </head> </head> </head> </head> </head> </head> </head> </head> </head> </head> </head> </head> </head> <- leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onkeydown="on_return();"> <form name ="loginForm" method="post" action="fuck.html"> <table cellpacing="0" cellpadding="0"> <tr> <td><span>Account name</span> <input type="text" name="userName" size="18.5"> </td> </tr> <tr> <td><span>Password</span> <input type="password" name="pwd" > </td> </tr> <tr> <td> <a id="sub" onClick='check()' > Log in</a></td> </tr> </table> </form></body></html><script Sprache = "javaScript"> Funktion check () {var formname = document.loginform; if (formname.username.value == "") {alert ("Bitte den Benutzernamen eingeben!"); Formname.username.focus (); false zurückgeben; } if (formname.pwd.value == "") {alert ("Bitte das Passwort eingeben!"); Formname.pwd.focus (); false zurückgeben; } formname.submit ();} // Bei der Eingabe wird die Standardeinstellung in die Funktion usreturn () {if (window.event.keyCode == 13) {if (document.All ('sub')! }}}}} </script>Beachten Sie hier: In <Body> fügen wir das Onkeydown -Attribut hinzu, so dass wir die JS -Methode direkt auf_return () direkt ausführen können. Denn wenn window.event.KeyCode 13 ist, bedeutet dies die Eingabetaste. Daher bestimmen wir, ob die Taste, die wir drücken, die Eingabetaste ist. Wenn ja, werden wir nach dem 'Sub' -Attribut suchen, und wenn es gefunden wird, wird es sein.
Ich hoffe, dass die in diesem Artikel beschriebenen Methoden für die Webprogrammierung aller hilfreich sein werden.