面向对象cookie增删查
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<input type="text" name="txt" id="txt" placeholder="用户名" />
<input type="text" name="password" id="password" placeholder="密码" />
<input type="button" name="reset" id="reset" value="重置" />
<input type="button" name="get" id="get" value="获取" />
</body>
<script src="js/cookie.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
function Cookie(){
this.oTxt=document.getElementById("txt");
this.oPd=document.getElementById("password");
this.oReset=document.getElementById("reset");
this.oGet=document.getElementById("get");
}
Cookie.prototype.setCookie=function(){
this.oTxt.onblur=function(){
this.setcookie('user',this.value,10);
}
this.oPd.onblur=function(){
this.setcookie('pwd',this.value,10);
}
}
Cookie.prototype.delCookie=function(){
var This=this;
this.oReset.onclick=function(){
This.oTxt.delcookie('user');
This.oPd.delcookie('pwd');
This.oTxt.value='';
This.oPd.value='';
}
}
Cookie.prototype.getCookie=function(){
var This=this;
this.oGet.onclick=function(){
alert(This.oTxt.getcookie('user'));
alert(This.oPd.getcookie('pwd'));
}
}
var cookie=new Cookie();
cookie.setCookie();
cookie.delCookie();
cookie.getCookie();
</script>
</html>
cookie.js
Object.prototype.setcookie=function( name,val,day){
this.oDate=new Date();//当前时间
this.oDate.setDate(this.oDate.getDate()+day);//过期时间
document.cookie=name+'='+val+';'+'expires='+this.oDate;
}
Object.prototype.delcookie=function( name ){
this.setcookie(name,1,-1);//利用过期时间
}
Object.prototype.getcookie=function( name ){
this.arr=document.cookie.split( '; ' );
for( var i=0;i<this.arr.length;i++ ){
this.arr1=this.arr[i].split('=');
if( this.arr1[0]==name ){
return this.arr1[1];
}
}
return 0;
}
面向对象cookie增删查的更多相关文章
- 6.在MVC中使用泛型仓储模式和依赖注入实现增删查改
原文链接:http://www.c-sharpcorner.com/UploadFile/3d39b4/crud-operations-using-the-generic-repository-pat ...
- 2015.8.2 jdbc实现商品类的增删查改
在惠普济宁基地进行了两周sql和java的学习,学到很多东西 刚才实现了用jdbc访问数据库对数据库进行操作,是用eclipse写的,过几天移植到NetBeans上,个人还是比较习惯看图形化界面 前几 ...
- IOS CoreData的(增删查改)
(1).CoreDataa>什么是CoreDatab>CoreData增删改查 "什么时候使用COredata 什么时候使用FMDatabases"CoreData 在 ...
- 基于.net的分布式系统限流组件 C# DataGridView绑定List对象时,利用BindingList来实现增删查改 .net中ThreadPool与Task的认识总结 C# 排序技术研究与对比 基于.net的通用内存缓存模型组件 Scala学习笔记:重要语法特性
基于.net的分布式系统限流组件 在互联网应用中,流量洪峰是常有的事情.在应对流量洪峰时,通用的处理模式一般有排队.限流,这样可以非常直接有效的保护系统,防止系统被打爆.另外,通过限流技术手段,可 ...
- 在MVC中使用泛型仓储模式和依赖注入实现增删查改
标签: 原文链接:http://www.c-sharpcorner.com/UploadFile/3d39b4/crud-operations-using-the-generic-repository ...
- 学习记录——使用PHP实现数据增删查改等基本功能(前后端分离)
萌新初次学习服务器端语言,分享学习经验 实现功能:1.显示数据表 2.对数据进行分页 3.对数据进行增删查改 由于本萌新采用前后端完全分离方案,所以数据传输用的ajax,为了提高代码的复用 ...
- 3.EF 6.0 Code-First实现增删查改
原文链接:http://www.c-sharpcorner.com/UploadFile/3d39b4/crud-operations-using-entity-framework-5-0-code- ...
- 4.在MVC中使用仓储模式进行增删查改
原文链接:http://www.c-sharpcorner.com/UploadFile/3d39b4/crud-using-the-repository-pattern-in-mvc/ 系列目录: ...
- 5.在MVC中使用泛型仓储模式和工作单元来进行增删查改
原文链接:http://www.c-sharpcorner.com/UploadFile/3d39b4/crud-operations-using-the-generic-repository-pat ...
随机推荐
- php日常日志写入格式记录
从数据库取出数据数组格式保存 file_put_contents('/tmp/bak_trusted_list'.date('H').'.php', '<?php return '.var_ex ...
- POJ-1028 Web Navigation 和TOJ 1196. Web Navigation
Standard web browsers contain features to move backward and forward among the pages recently visited ...
- GDUFE-OJ 1070上班打卡 ^位运算
Problem Description: 某公司上班使用打卡制度,员工需要在打卡机器上打入和打出才算上班.每个员工都有自己对应编号K,编号为一个整数(1 <= K <=50000),某天有 ...
- AndroidManifest.xml详解(上)
本文编辑整理自:http://blog.163.com/hero_213/blog/static/39891214201242835410742/ 一.关于AndroidManifest.xml ...
- NSJSONSerialization(json序列化)
//通过调用isValidJSONObject来判断Foundation对象是否可以转换为JSON数据 NSJSONSerialization isValidJSONObject:obj 我们能利用N ...
- asp.net mvc bundle中数组超出索引
在使用bundle 来加载css的时候报错了, @Styles.Render("~/bundles/appStyles") 第一反应 以为是的css 太多了,可是当我这个style ...
- 剑指offer五:
输入两个单调递增的链表,输出两个链表合成后的链表,当然我们需要合成后的链表满足单调不减规则. /* public class ListNode { int val; ListNode next = n ...
- CPU过高的排查方法
一个应用占用CPU很高,除了确实是计算密集型应用之外,通常原因都是出现了死循环. (友情提示:本博文章欢迎转载,但请注明出处:hankchen,http://www.blogjava.net/hank ...
- [SoapUI] 在SoapUI里获取Excel中多行数据并存入List
ArrayList<ArrayList<String>> getCellValuesH( String filePath, String sheetName,int tr1,i ...
- 写日志 log 到文件夹
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threa ...