Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/87.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何为浏览器实现pathStorage samelike会话存储?_Javascript_Html_Local Storage - Fatal编程技术网

Javascript 如何为浏览器实现pathStorage samelike会话存储?

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); }

当我读到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._getItem = Storage.prototype.getItem;
Storage.prototype.getItem = function(key)
{
_key = window.location.pathname + ":" + key;
return this._getItem(_key);
}
但这个问题只适用于本地存储和会话存储


我想要一种新的pathStorage,而不覆盖localStorage和sessionStorage。

您的实际问题是什么?创建pathStorage,其中密钥只能在创建时访问。