30天内免登陆(cookie)
来源:互联网 发布:时时彩开奖软件 编辑:程序博客网 时间:2024/05/21 05:43
<!DOCTYPE html><html><head><meta charset="UTF-8"><title>30天内免登陆</title></head><body><form><input type="text" placeholder="用户名" /><br /><input type="password" placeholder="密码" /><br /><input type="checkbox" />30天内免登陆<br /><button>登录</button><!--这个地方如果是submit,他会重新刷新--><input type="reset" /></form><script>var username = document.querySelectorAll("input")[0]; //获取input节点类型var password = document.querySelectorAll("input")[1];var check = document.querySelectorAll("input")[2];var sub = document.querySelector("button");//选单个元素没有allfunction rewrite() {console.log(document.cookie)var arr = document.cookie.split("; ");for(var i = 0; i < arr.length; i++) {var arr2 = arr[i].split("=");if(arr2[0] == "checkvalue" && arr2[1] == "true") {//判断是否选择免登陆//选择免登陆要重新遍历数组,否则还会是原来的值for(var j = 0; j < arr.length; j++) {var arr3 = arr[j].split("=");if(arr3[0] == "usname") //注意双等,获取{console.log('有用户名');username.value = arr3[1];} else if(arr3[0] == "psd") {console.log('有密码');password.value = arr3[1];} else if(arr3[0] == "checkvalue") {console.log('是免登陆');console.log(arr3[1])check.checked = arr3[1] == "true" ? true : false; //字符串转化为布尔值console.log(check.checked)}}}}}rewrite()/*console.log(arr);*///点击登录保存用户名、密码和登录状态sub.addEventListener("click", function() { //给sub添加点击事件,匿名函数var usname = username.value;var psd = password.value;var checkvalue = check.checked;console.log(usname, psd, checkvalue);var date = new Date();date.setDate(date.getDate() + 30); //设置天数document.cookie = "usname=" + usname + ";expires=" + date;document.cookie = "psd=" + psd + ";expires=" + date;document.cookie = "checkvalue=" + checkvalue + ";expires=" + date;})</script></body></html>
阅读全文
0 0
- 30天内免登陆(cookie)
- 网站登陆Cookie是什么
- 使用cookie 记录登陆
- PHP用cookie登陆
- Cookie实习登陆次数
- cookie实现登陆
- 【ci框架】cookie登陆
- Cookie实现自动登陆
- js实现cookie登陆
- 自动登陆--Cookie
- 采集之cookie登陆
- struts中的cookie登陆
- cookie实现自动登陆
- 模拟新浪微博登陆(直接调用cookie方法)
- Cookie学习总结-登陆案例(记住用户名和密码)
- UIWebView实现自动登陆(存储、读取Cookie)
- cookie的实现登陆次数
- cookie+memcached实现单点登陆
- 机器学习:决策树cart算法在分类与回归的应用(下)
- (学习笔记)设计模式之策略模式
- vim 出现 highlight group not found: Normal
- CentOS 系统下终端从普通用户切换到root用户的方法
- 使图片拥有ID及获取图片的值
- 30天内免登陆(cookie)
- cannot be resolved in either web.xml or the jar files deployed with this application
- Python常用的格式化符号
- CNN学习(三)—Tensorflow 进行MNIST手写体识别
- 对MVP简单的理解
- ThreadLocal类分析
- 语音芯片WTN6的类
- 用matlab 对图像进行 拉普拉斯锐化
- Hibernate对象状态、缓存、快照、hql语句、criteria语句、sql语句