Welcome
We've been working hard

JS's method of login by pressing Enter

Henan SEO today talked about how JS can login by pressing the Enter key. This function has a wide range of practical values. Share it for your reference. The specific methods are as follows:

Method 1:

  <html xmlns=” http://www.w3.org/1999/xhtml ” >

<head>

<title>Check Score</title>

<script language=”JavaScript”>

function keyLogin(){

If (event. keyCode==13)//The value of the Enter key is 13

Document. getElementByIdx_x ("input1 ″). click();//The login event that calls the login button

}

</script>

</head>

<body onkeydown=”keyLogin();”>

<input id="input1" value="Login" type="button" onClick="alert ('Call succeeded! ')">

</body>

</html>

Method 2:

  <script>

function KeyDown()

{

if (event.keyCode == 13)

{

event.returnValue=false;

event.cancel = true;

Form1.btnsubmit.click();

}

}

</script>

Method 3:

Every website page has a login interface. Most of the time, after entering the user name and password, you need to click a button or link similar to login with the mouse, so that you can enter the website and do what you like

Sometimes I wonder if I can execute the login function after I input the things I should input, and then directly click Enter? The solution is as follows:

Ss.html Page code:

<html>

<head>

<title></title>

<meta http-equiv=”Content-Type” content=”text/html; charset=gb2312″>

<link rel=”stylesheet” href=”css/text.css” type=”text/css”>

</head>

<body bgcolor=”#FFFFFF” text=”#000000″ leftmargin=”0″ topmargin=”0″ marginwidth=”0″ marginheight=”0″ onkeydown=”on_return();”>

<form name =”loginForm” method=”post” action=”fuck.html”>

<table width=”100%” border=”0″ cellspacing=”0″ cellpadding=”0″>

<tr>

<td width="69%" height="30 ″><span class=" font_04 ″>Account Name</span>

<input type=”text” name=”userName” size=”18.5″>

</td>

</tr>

<tr>

<td width="69%" height="30 ″>Password</span>

<input type=”password” name=”pwd” >

</td>

</tr>

<tr>

<td width=”31%” height=”30″>

<a id=”sub” onClick=’check()’ >

Login</a></td>

</tr>

</table>

</form>

</body>

</html>

<script language=”javascript”>

function check() {

var formname=document.loginForm;

if (formname.userName.value == “”) {

Alert ("Please enter the user name!");

formname.userName.focus();

return false;

}

if (formname.pwd.value == “”) {

Alert ("Please enter the password!");

formname.pwd.focus();

return false;

}

formname.submit();

}

//When entering, the default is login

function on_return(){

if(window.event.keyCode == 13){

if (document.all(‘sub’)!= null){

document.all(‘sub’).click();

}

}

}

</script>

Note here: In<body>, we add the onkeydown attribute, so that after entering the content, we can directly execute the on_return() JS method by pressing the key. Because if the window.event.keyCode is 13, it means the carriage return key, so we judge whether the key we pressed is the carriage return key, if it is, we will find the 'sub' attribute, and if the click method is found, we will execute it.

today Henan SEO So far, I hope it can help you.

Like( zero ) Reward
Do not reprint without permission: New Start Blog » JS's method of login by pressing Enter


Follow the public account "New Start Software Steward"

Get the latest network resources and cracking software!
Play with all kinds of software

comment Grab the sofa

You must log in before commenting!

 

Reward the author of the article if you think it is useful

Thank you very much for your reward, we will continue to give more high-quality content, let's create a better online world together!

Scan Alipay and reward

Scan WeChat and reward