有没有办法在谷歌的Chrome浏览器上禁用同源策略?
当前回答
在Windows中:
创建快捷方式并设置目标:
“C:\Program Files\Google\Chrome\Application\Chrome.exe”--禁用站点隔离测试--禁用web安全--用户数据dir=“C:\ChromeDevSession”
其他回答
在Windows 10上,以下功能将起作用。
<<path>>\chrome.exe --allow-file-access-from-files --allow-file-access --allow-cross-origin-auth-prompt
关闭chrome(或chrome)并使用--disable web安全参数重新启动。我刚刚测试了这个,并验证了我可以使用src=“”访问iframe的内容http://google.com嵌入在“localhost”(在chromium 5/ubuntu下测试)提供的页面中
注意:在运行命令之前杀死所有chrome实例
chromium-browser --disable-web-security --user-data-dir="[some directory here]"
浏览器首次打开时会警告您“您正在使用不受支持的命令行”,您可以忽略这一点。
铬源:
// Don't enforce the same-origin policy. (Used by people testing their sites.)
const wchar_t kDisableWebSecurity[] = L"disable-web-security";
在Chrome 48之前,您可以使用:
chromium-browser --disable-web-security
对于Selenium Webdriver,在这种情况下,您可以使用适当的参数(或“开关”)让Selenium启动Chrome。
@driver = Selenium::WebDriver.for(:Chrome, {
:detach => false,
:switches => ["--disable-web-security"]
})
若您在Linux上使用Google Chrome,则以下命令有效。
google-chrome --disable-web-security
对于Windows。。。在桌面上创建Chrome快捷方式。右键单击>财产>快捷方式编辑“目标”路径:
"C:\Program Files\Google\Chrome\Application\chrome.exe" --args --disable-web-security
(将“C:….\chrome.exe”更改为chrome所在的位置)。
等等:)