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     ]

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM