JS press the Enter key to log on. js press the Enter key to log on.
This article describes how to log on by pressing the Enter key in JS. This function has a wide range of practical values. Share it with you for your reference. The specific method is as follows:
Method 1:
<Html xmlns = "http://www.w3.org/1999/xhtml">
Method 2:
<script>function KeyDown(){ if (event.keyCode == 13) { event.returnValue=false; event.cancel = true; Form1.btnsubmit.click(); }}</script>
Usage:
<Form name = "Form1" method = ""> Username: <input type = text SIZE = 20 maxlength = 8 onkeydown = KeyDown ()> password: <input type = password SIZE = 20 maxlength = 8 onkeydown = KeyDown ()> <input type = "submit" name = "btnsubmit" value = "submit"/> </form>
Method 3:
Any website page has a logon interface. Many times, after you have entered your username and password, you need to click a button or link similar to what you are logging on. in this way, you can enter the website to do what you like.
Sometimes I wonder if I can directly press enter to execute the login function after entering the input? The solution is as follows:
Ss.html Page code:
<Html>
HereNote:In <body>, we added the onkeydown attribute so that after entering the content, we can press the key to directly execute the JS method on_return. because window. event. if the keyCode is 13, it indicates the Enter key. Therefore, we can judge whether the key we press is a return key. If so, we can find the 'sub 'attribute. If we find the key, we can execute the click method.
I hope the method described in this article will be helpful for your web programming.
How does js achieve the same effect as clicking the mouse? The code is concise and compatible with the following demo:
<Form method = "post" name = "" action = "" onkeydown = "javascript: if (event. keyCode = 13) this. submit ();">
<Input type = "text" name = "" value = "" maxlength = "" placeholder = "input data here"/> <br/>
<Input type = "submit" name = "" value = "after entering data, click here or press the Enter key to execute" id = ""/>
</Form>
How does ASP or JS implement a page button and press enter as the shortcut key?
Write down JS events, capture keys, judge, and execute the process you want.
Function document. onkeydown () // trigger by pressing enter in the webpage
{
If (event. keyCode = 13)
{
// Here is the process.
Form1.submit (); // submit
// Alert ("OK ");
Return false;
}
}