[javascript] 报错SecurityError: Failed to read the 'localStorage' property from 'Window

当使用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.

 

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

            if(navigator.cookieEnabled&&typeof window.localStorage !== 'undefined') {
      
            }

 [javascript] 报错SecurityError: Failed to read the 'localStorage' property from 'Window

 

上一篇:js-cookie的使用


下一篇:redux和sessionStorage,localStorage的区别