有没有办法在谷歌的Chrome浏览器上禁用同源策略?
当前回答
对于Windows:
打开开始菜单键入windows+R或打开“运行”执行以下命令:chrome.exe--user data dir=“C:\/chrome dev session”--禁用web安全
对于Mac:
转到终端执行以下命令:open/Applications/Google\Chrome.app--args--用户数据dir=“/var/tmp/Chrome-dev会话”--禁用web安全
新的禁用web安全的chrome浏览器将打开,并显示以下消息:
对于Mac
如果您想在不关闭现有选项卡的情况下打开禁用web安全的Chrome浏览器的新实例,请使用以下命令
open -na Google\ Chrome --args --user-data-dir=/tmp/temporary-chrome-profile-dir --disable-web-security
它将打开禁用web安全的Chrome浏览器的新实例,如下所示
其他回答
在Windows PC上,使用较旧版本的Chrome,该命令将适用于所有人。我把我的Chrome降到了26版,而且效果不错。
关闭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
对于Windows。。。在桌面上创建Chrome快捷方式。右键单击>财产>快捷方式编辑“目标”路径:
"C:\Program Files\Google\Chrome\Application\chrome.exe" --args --disable-web-security
(将“C:….\chrome.exe”更改为chrome所在的位置)。
等等:)
您可以简单地使用这个chrome扩展名Allow Control Allow Origin
只需单击扩展图标即可根据需要打开或关闭跨资源共享
在Windows 10上,以下功能将起作用。
<<path>>\chrome.exe --allow-file-access-from-files --allow-file-access --allow-cross-origin-auth-prompt