当Chrome浏览器使用iframe页面调用其他页面时会提示:"Uncaught DOMException: Blocked a frame with origin "null" from accessing a cross-origin frame"。
但是IE和Edge是没有问题的。
原因:Chrome 认为其跨域不安全。
解决办法:launch.json里面加上配置:
完整配置文件如下:
"version": "0.2.0",
"configurations": [
{
"name": "使用本机 Chrome 调试",
"type": "chrome",
"request": "launch",
"file": "${workspaceRoot}/index.html",
//"url": "http://mysite.com/index.html", //使用外部服务器时,请注释掉 file, 改用 url, 并将 useBuildInServer 设置为 false "http://mysite.com/index.html
"runtimeExecutable": "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe", // 改成您的 Chrome 安装路径
"sourceMaps": false,
"webRoot": "${workspaceRoot}",
// "preLaunchTask":"build",
"userDataDir":"${tmpdir}",
"port":5433
,"runtimeArgs": [
" --disable-web-security" //跨域访问,不安全,仅本地测试
]
}
]