【问题标题】:After disabling web security I still cannot overcome same origin policy禁用网络安全后,我仍然无法克服同源策略
【发布时间】:2015-09-20 11:14:48
【问题描述】:

我在 OS X 上使用 google chrome 版本 43.0.2357.81 并尝试在 iframe 中显示网页。 即:

我按照此链接的说明禁用网络安全,发现它有助于在 iframe 中显示本地文件,但在尝试显示不同的网页时仍然遇到相同来源的错误。

Disable same origin policy in Chrome

我在终端中运行命令 open -a Google\ Chrome --args --disable-web-security 并收到横幅消息,确认它有效:

您正在使用不受支持的命令行标志:--disable-web-security。稳定性和安全性将受到影响。

但是,当我在 chrome 中查看我的网页时,我仍然遇到相同的来源错误,并且无法在 iframe 中查看该网站。

【问题讨论】:

    标签: html google-chrome iframe


    【解决方案1】:

    这与 Chrome 本身无关;您在 iframe 中调用的服务器通过

    发回一个 http 标头
    X-Frame-Options  SAMEORIGIN
    

    设置。即使“chrome.exe --user-data-dir=c:\tmp\chrome2 --allow-file-access-from-files --disable-web-security”也不会禁用 Chrome 中的 iframe 同源检查。您唯一的选择是将服务器的 X-Frame-Options 切换到

    X-Frame-Options  ALLOWALL
    

    (如果可以的话)。

    【讨论】:

      猜你喜欢
      • 2016-12-11
      • 2021-05-08
      • 2011-07-20
      • 2014-01-29
      • 2017-12-27
      • 2014-03-23
      • 2013-06-09
      • 2012-08-12
      相关资源
      最近更新 更多