How to log on using JS to remember the password and enter on the logon page _ javascript tips

Source: Internet
Author: User
The following small series will bring you a JS login page to remember the password and enter key login method recommended. I think it is quite good. Now I will share it with you and give you a reference.
 Press enter to trigger the event and remember the account passwordScript // Method 1: // document. onkeypress = function (e) {// var keycode = document. all? Event. keyCode: e. which; // if (keycode = 13) {// alert_login (); //}; // Method 2: document. onkeypress = viewKeyInfo; function viewKeyInfo (e) {var e = e | event; if (e ['keycode'] = 13) | (e ['which '] = 13) {alert_login () ;}} function body_onload () {if (1 = get_saveauth_cookies ()) {var tmp_user = ''; var tmp_pwd =''; tmp_user = get_user_cookies (); tmp_pwd = get_pwd_cookies (); document. getElementById ("tt_user "). value = tmp_user; document. getElementById ("pd_pwd "). value = tmp_pwd; document. getElementById ("chx_save_auth "). checked = true ;}} function alert_login () {if (document. getElementById ("chx_save_auth "). checked = true) {var cookies_uesr = document. getElementById ("tt_user "). value; var cookies_pwd = document. getElementById ("pd_pwd "). value; setcookie ('loginuser', cookies_uesr, 1440); setcookie ('loginpwd', cookies_pwd, 1440); setcookie ('saveauth', 1, 1440 );} else {setcookie ('saveauth ', 0, 1440);} location =" https://www.baidu.com ";} Function setcookie (name, value, expirehours) {var cookieString = name + '=' + escape (value); if (expirehours> 0) {var date = new Date (); date. setTime (date. getTime () + expirehours * 3600*1000); cookieString = cookieString + '; expires =' + date. toGMTString (); document. cookie = cookieString;} document. cookie = cookieString;} function getcookie (name) {var strCookie = document. cookie; var arrCookie = strCookie. split (';'); for (var I = 0; I

User:

Password:

Save password

The above JS implementation login page remembers the password and enter key login method recommended is all the content shared to you by xiaobian, hope to give you a reference, also hope you can support more.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.