Home >Web Front-end >JS Tutorial >Using window.name to implement windowStorage code sharing_javascript skills
read: function(key) {
if (!this._inited) {
throw new Error('Please initialize before reading.');
}
return this._data[key];
},
write: function(key, value) {
var str = [];
if (!this._inited) {
throw new Error('Please initialize before writing.');
}
this._data[key] = value;
for (var k in this._data) {
str.push(escape(k) ':' escape(this._data[k]));
}
window.name = str.join('|');
}
};