Uncaught DOMException: Blocked a frame with origin "null" from accessing a cross-origin frame.

  工具环境:Layui 框架下使用VS Code进行Chrome 调试。

  问题描述:当Chrome浏览器使用iframe页面调用其他页面时会提示:"Uncaught DOMException: Blocked a frame with origin "null" from accessing a cross-origin frame"。

      但是IE和Edge是没有问题的。

  原因:Chrome 认为其跨域不安全。

  解决办法:launch.json里面加上配置:

      ,"runtimeArgs": [
        " --disable-web-security"
      ]
  完整配置文件如下:
 1    "version": "0.2.0",
 2     "configurations": [
 3         {
 4             "name": "使用本机 Chrome 调试",
 5             "type": "chrome",
 6             "request": "launch",
 7             "file": "${workspaceRoot}/index.html",
 8             //"url": "http://mysite.com/index.html", //使用外部服务器时,请注释掉 file, 改用 url, 并将 useBuildInServer 设置为 false "http://mysite.com/index.html
 9             "runtimeExecutable": "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe", // 改成您的 Chrome 安装路径
10             "sourceMaps": false,
11             "webRoot": "${workspaceRoot}",
12         //  "preLaunchTask":"build",
13             "userDataDir":"${tmpdir}",
14             "port":5433
15             ,"runtimeArgs": [  
16                 " --disable-web-security"   //跨域访问,不安全,仅本地测试
17             ]
18         }
19     ]

 

posted @ 2019-02-25 10:06  PengRay  阅读(9153)  评论(0编辑  收藏  举报