解决 Failed to read the ‘localStorage‘ property from ‘Window‘: Access is denied...

当使用chrome 无痕模式时, 默认阻止第三方cookie、localStorage 导致报错
更新于: 2022-06-07 11:22:05

问题

当使用chrome 无痕模式时, 默认阻止第三方cookie

如果使用了localStorge或者cookie , 就会在js里报错

报错SecurityError: Failed to read the 'localStorage' property from 'Window': Access is denied for this document.

Failed to read the 'localStorage' property from 'Window': Access is denied for this document.

这个问题只能在代码层面做兼容处理 ,先不让报错

设置 cookie
打开隐私按钮

参考