gpt4 book ai didi

javascript - 有没有办法在不同的选项卡之间隔离 'localStorage'?

转载 作者:行者123 更新时间:2023-11-29 22:57:36 25 4
gpt4 key购买 nike

我目前正在使用 window.localStorage 在浏览器上存储一些客户端数据。但我想将此存储隔离到各个选项卡。

有什么办法可以实现吗?

最佳答案

您应该考虑使用 sessionStorage 改为:

sessionStorage is similar to localStorage; the only difference is while data stored in localStorage has no expiration time, data stored in sessionStorage gets cleared when the page session ends. A page session lasts for as long as the browser is open and survives over page reloads and restores. Opening a page in a new tab or window will cause a new session to be initiated with the value of the top-level browsing context [...]

关于javascript - 有没有办法在不同的选项卡之间隔离 'localStorage'?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56349852/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com