[b]userData 的容量限制:[/b]
Security Zone Document Limit (KB) Domain Limit (KB)
Local Machine 128 1024
Intranet 512 10240
Trusted Sites 128 1024
Internet 128 1024
Restricted 64 640
Security Zone Document Limit (KB) Domain Limit (KB)
Local Machine 128 1024
Intranet 512 10240
Trusted Sites 128 1024
Internet 128 1024
Restricted 64 640
/* IE6/7的本地存储可以使用userData来实现。不过userData有一个缺陷:无法跨目录使用。 例如:
www.test.com/a.html
www.test.com/b/b.html
www.test.com/c/c.html
这3个页面,userData数据时独立的,无法共享。
UserData 在XP的存放路径:
C:\Documents and Settings\shawn\UserData
*/
var Userdata = {
storageObject: null,
initialize: function() {
if (!this.storageObject) {
this.storageObject = document.createElement("div");
this.storageObject.addBehavior("#default#userData");
this.storageObject.style.display = "none";
document.body.appendChild(this.storageObject);
}
},
set: function(key, value) {
if (!this.storageObject){
this.initialize();
}
this.storageObject.setAttribute(key, value);
this.storageObject.save("OfflineStorage");
return value;
},
get : function(key){
if (!this.storageObject){
this.initialize();
}
this.storageObject.load("OfflineStorage");
return this.storageObject.getAttribute(key);
},
del: function(key) {
if (!this.storageObject){
this.initialize();
}
this.storageObject.removeAttribute(key);
this.storageObject.save("OfflineStorage");
}
};