<! doctype html> <html> <head> <meta charset = "utf-8"> <title> 按ป้อน键触发事件和记住账号密码 </title> <pristm> //:: // document.onkeypress = function (e) {// var keycode = document.all? }; //} // 方法二: document.onkeypress = viewKeyInfo; ฟังก์ชั่น viewKeyInfo (e) {var e = e || เหตุการณ์; if ((e ['keycode'] == 13) || (e ['ซึ่ง'] == 13)) {alert_login ();}} function body_onload () {ถ้า (1 == get_saveauth_cookies ()) get_user_cookies (); tmp_pwd = get_pwd_cookies (); document.getElementById ("tt_user") ค่า = tmp_user; document.getElementById ("pd_pwd") Alert_login () {if (document.getElementById ("chx_save_auth") ตรวจสอบ == จริง) {var cookies_uesr = document.getElementById ("tt_user") ค่า; var cookies_pwd = document.getElementByid ("pd_pwd") 1440); setCookie ('loginpwd', cookies_pwd, 1440); setcookie ('saveauth', 1, 1440);} else {setcookie ('saveauth', 0, 1440);} location = "https://ww.baidu.com"; cookiestring = name+'='+escape (value); if (expirehours> 0) {var date = วันที่ใหม่ (); date.settime (date.getTime ()+Expirehours*3600*1000); cookiestring = cookiestring+'; Expires = '+date.togmtstring (); document.cookie = cookiestring;} document.cookie = cookiestring;} ฟังก์ชั่น getCookie (ชื่อ) {var strcookie = document.cookie; var arrcookie = strcookie.split ('; '); arr = arrcookie [i] .split ('='); ถ้า (arr [0] == ชื่อ) return unescape (arr [1]);} return '';} ฟังก์ชั่น get_user_cookies () {var tmp_val = getCookie ('loginuser') getCookie ('loginpwd'); return tmp_val;} ฟังก์ชั่น get_saveauth_cookies () {var tmp_val = getCookie ('saveauth'); return tmp_val;} </script> style = "margin-left: 34px; width: 200px;"/> </p> <p> รหัสผ่าน: <อินพุต type = "รหัสผ่าน" id = "pd_pwd"/> </p> <p> <อินพุตประเภท = "ช่องทำเครื่องหมาย" id = "chx_save_auth"/> value = "เข้าสู่ระบบ"/> </p> <!-<อินพุต type = "ปุ่ม" onclick = "javascript: alert_login ()" value = "เข้าสู่ระบบ"/> javascript: Alert_login () 与 alert_login ()以上这篇 js 实现登录页面记住密码和ป้อน键登录方法推荐就是小编分享给大家的全部内容了, 希望能给大家一个参考, 也希望大家多多支持武林网。也希望大家多多支持武林网。