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

当使用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') {
      
            }

 

 

posted @ 2021-03-15 11:10  陶士涵  阅读(36)  评论(0编辑  收藏