JS localStorage 存储变量

JS localStorage 存储变量
 1 if(!window.localStorage && /MSIE/.test(navigator.userAgent)){ 
 2         if(!window.UserData) { 
 3             window.UserData = function(file_name) { 
 4                 if(!file_name) file_name="user_data_default"; 
 5                 var dom = document.createElement(‘input‘); 
 6                 dom.type = "hidden"; 
 7                 dom.addBehavior ("#default#userData"); 
 8                 document.body.appendChild(dom); 
 9                 dom.save(file_name); 
10                 this.file_name = file_name; 
11                 this.dom = dom; 
12                 return this; 
13             };
14     
15             window.UserData.prototype = { 
16                 setItem:function(k, v) { 
17                     this.dom.setAttribute(k,v); 
18                     this.dom.save(this.file_name); 
19                 }, 
20                 getItem:function(k){ 
21                     this.dom.load(this.file_name); 
22                     return this.dom.getAttribute(k); 
23                 }, 
24                 removeItem:function(k){ 
25                     this.dom.removeAttribute(k); 
26                     this.dom.save(this.file_name); 
27                 },
28                 clear:function() { 
29                    this.dom.load(this.file_name); 
30                    var now = new Date(); 
31                    now = new Date(now.getTime()-1); 
32                    this.dom.expires = now.toUTCString(); 
33                    this.dom.save(this.file_name); 
34                 }
35             }; 
36         } 
37         window.localStorage= new window.UserData("local_storage"); 
38     }
JS localStorage 存储变量

JS localStorage 存储变量,布布扣,bubuko.com

JS localStorage 存储变量

上一篇:PHP-----类与对象,成员方法,成员属性,构造方法,析构方法


下一篇:SpringMvc - HttpMessageConverter