gpt4 book ai didi

javascript - chrome隐身模式下的LocalStorage

转载 作者:行者123 更新时间:2023-12-03 06:51:24 30 4
gpt4 key购买 nike

所以在我的 Angular 1.5 应用程序中,我还想在页面加载时保留数据,
所以我使用$window.localStorage .
我正在从 localStorage 中读取一些值它在隐身模式下也能正常工作。The page refreshes and yet the values are retained .

if($window.localStorage.selectedServers !== undefined)
selectedObj = JSON.parse($window.localStorage.selectedServers);
问题是
当我复制网址并在新标签页中以隐身方式打开时,
localStorage 变得不确定。
如何摆脱这个问题?或者我做错了什么?

最佳答案

When I copy the Url and open in a new tab incognito itself,

The localStorage gets undefined.


这是因为正如评论中提到的,隐身/隐私浏览窗口不会保留本地/ session 存储。因此,当您打开一个新选项卡时,它们是空的。

关于javascript - chrome隐身模式下的LocalStorage,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44857187/

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