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

  工具環境:Layui 框架下使用VS Code進行Chrome 調試。html

  問題描述:當Chrome瀏覽器使用iframe頁面調用其餘頁面時會提示:"Uncaught DOMException: Blocked a frame with origin "null" from accessing a cross-origin frame"。web

      可是IE和Edge是沒有問題的。chrome

  緣由:Chrome 認爲其跨域不安全。json

  解決辦法: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     ]
相關文章
相關標籤/搜索