0

我正在尝试将我的网站 www.drewgl.com 中的一些页面添加到 stumbleupon。它非常依赖于javascript。当我通过 stumbleupon 查看我的网站时,javascript 被阻止。具体来说,我看到了错误:

未捕获的安全错误:阻止具有来源“ http://www.drewgl.com ”的框架访问具有来源“ http://www.stumbleupon.com ”的框架。协议、域和端口必须匹配

我正在使用部署到heroku的rails 4。我将 X 帧选项设置为允许所有选项。我在这里通读了答案: SecurityError: Blocked a frame with origin from access a cross-origin frame ,似乎解决此问题的唯一方法是使用 window.postmessage 在两个页面之间发送消息。但是,要做到这一点,您必须拥有这两个页面。

当然,Stumbleupon 无法满足这个条件,那么我该如何解决这个问题呢?

编辑:我刚刚下载了 chrome 的 stumbleupon 工具栏。执行此操作后,我不再收到上述错误消息。无论哪种方式,我仍然想为没有工具栏的绊脚石解决这个问题。

4

2 回答 2

1

没有在 StumbleUpon 上加载 Rails 应用程序?将此添加到您的 ApplicationController

  before_action :allow_iframe_requests

private

  def allow_iframe_requests
    response.headers.delete('X-Frame-Options')
  end

https://github.com/rails/rails/issues/6311

于 2017-05-13T19:44:35.663 回答
0

弄清楚了。如果有人好奇,则不允许您从 iframe 中访问当前路径。这段代码导致了这个问题:

//     if (top.location.pathname === '/users/sign_in')
// {
//     $('#login').modal('show');
// }
于 2016-08-01T19:53:06.910 回答