Javascript 如何为浏览器实现pathStorage samelike会话存储?
当我读到sessionStorage和localStorage时,我想要的和pathStorage一样 我看到的一些,并像这样覆盖存储Javascript 如何为浏览器实现pathStorage samelike会话存储?,javascript,html,local-storage,Javascript,Html,Local Storage,当我读到sessionStorage和localStorage时,我想要的和pathStorage一样 我看到的一些,并像这样覆盖存储 Storage.prototype._setItem = Storage.prototype.setItem; Storage.prototype.setItem = function(key, value) { _key = window.location.pathname + ":" + key; this._setItem(_key, value); }
Storage.prototype._setItem = Storage.prototype.setItem;
Storage.prototype.setItem = function(key, value)
{
_key = window.location.pathname + ":" + key;
this._setItem(_key, value);
}
Storage.prototype._getItem = Storage.prototype.getItem;
Storage.prototype.getItem = function(key)
{
_key = window.location.pathname + ":" + key;
return this._getItem(_key);
}
但这个问题只适用于本地存储和会话存储
我想要一种新的pathStorage,而不覆盖localStorage和sessionStorage。您的实际问题是什么?创建pathStorage,其中密钥只能在创建时访问。