有没有办法在谷歌的Chrome浏览器上禁用同源策略?
当前回答
关闭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
其他回答
chromium-browser --disable-web-security --user-data-dir=~/ChromeUserData/
对于Windows。。。在桌面上创建Chrome快捷方式。右键单击>财产>快捷方式编辑“目标”路径:
"C:\Program Files\Google\Chrome\Application\chrome.exe" --args --disable-web-security
(将“C:….\chrome.exe”更改为chrome所在的位置)。
等等:)
对于mac用户:
open -a "Google Chrome" --args --disable-web-security --user-data-dir
在Chrome 48之前,您可以使用:
open -a "Google Chrome" --args --disable-web-security
根据奥拉·卡尔森的回答,最好的方法是在不同的会话中打开不安全的Chrome。这样,您就不必担心关闭所有当前打开的选项卡,也可以使用原始的Chrome会话继续安全地上网。
这些批处理文件应该只适用于Windows。
将其放在Chrome_CORS.bat文件中以便于使用
start "" "c:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --user-data-dir="c:/_chrome_dev" --disable-web-security
这张是给Chrome Canary的。金丝雀_ CORS.bat
start "" "c:\Users\%USERNAME%\AppData\Local\Google\Chrome SxS\Application\chrome.exe" --user-data-dir="c:/_canary_dev" --disable-web-security
在Ubuntu中使用以下命令启动chrome(禁用同源策略并在分离模式下打开chrome):
nohup google-chrome --disable-web-security --user-data-dir='/tmp' &