Java教程

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

本文主要是介绍[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的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!