JS实现两周内自动登录功能

软件发布|下载排行|最新软件

当前位置:首页IT学院IT技术

JS实现两周内自动登录功能

xing.org1^   2020-05-15 我要评论

本文实例为大家分享了Android九宫格图片展示的具体代码,供大家参考,具体内容如下

<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8">
    <title>两周内自动登录</title>
    <script src="cookie.js" type="text/javascript" charset="utf-8"></script>
  </head>
  <body>
    <form action="" method="post" id="form1">
      <input type="text" name="user" id="user" value="" />
      <input type="password" name="pass" id="pass" value="" />
      <input type="submit" value="提交" id="btn"/>
      <input type="checkbox" name="checkbox" id="checkbox" value="" />两周内自动登录
    </form>
    
  </body>
  <script type="text/javascript">
    var oTxt1 = document.getElementsByName('user')[0],
      oTxt2 = document.getElementsByName('pass')[0],
      cked = document.getElementsByName('checkbox')[0],
      oForm1 = document.getElementById('form1'),
      oBtn = document.getElementById('btn');
    oForm1.onsubmit = function(){
      if(cked.checked){
        alert('请注意!您已勾选自动登录。为了保护您的账号安全,请不要在公共电脑上这样做。')
        setCookie('user',oTxt1.value,14);
        setCookie('pass',oTxt2.value,14);  
      }
    }
    oTxt1.value = getCookie('user');
    oTxt2.value = getCookie('pass');
  </script>
</html>

来自智能社的学习笔记延伸练习。

Copyright 2022 版权所有 软件发布 访问手机版

声明:所有软件和文章来自软件开发商或者作者 如有异议 请与本站联系 联系我们