Uncaught DOMException: Blocked a frame with origin “null” from accessing a cross-origin…

Tool environment: use vs code to debug chrome in layui framework

Problem Description: when Chrome browser calls other pages with iframe page, it will prompt: “uncaught domexception: blocked a frame with origin” null “from accessing a cross origin frame”

But there is no problem with IE and edge

Reason: Chrome thinks it is not secure across domains

Solution: add configuration in launch.json

,”runtimeArgs”: [

” –disable-web-security”

]

The complete configuration file is as follows:

1    "version": "0.2.0",
 2     "configurations": [
 3         {
 4             "name": "Debugging with native Chrome",
 5             "type": "chrome",
 6             "request": "launch",
 7             "file": "${workspaceRoot}/index.html",
 8             //"url": "http://mysite.com/index.html", //When using an external server, please comment out the file, use the url instead, and set useBuildInServer to false "http://mysite.com/index.html
 9 "runtimeExecutable": "C:\\Program Files (x86)\Google\\Chrome\\Application\\chrome.exe", // change it to your Chrome installation path
10             "sourceMaps": false,
11             "webRoot": "${workspaceRoot}",
12         //  "preLaunchTask":"build",
13             "userDataDir":"${tmpdir}",
14             "port":5433
15             ,"runtimeArgs": [  
16                 " --disable-web-security"   //Cross-domain access, insecure, local testing only
17             ]
18         }
19     ]

Similar Posts: