[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') {
      
            }

 

开源作品

GO-FLY,一套可私有化部署的免费开源客服系统,安装过程不超过五分钟(超过你打我 !),基于Golang开发,二进制文件可直接使用无需搭开发环境,下载zip解压即可,仅依赖MySQL数据库,是一个开箱即用的网页在线客服系统,致力于帮助广大开发者/中小站长快速整合私有客服功能
github地址:go-fly
官网地址:https://gofly.sopans.com

赞赏作者

微信交流

原文地址:https://www.cnblogs.com/taoshihan/p/14536446.html