【问题标题】:Best possible SEO way of forcing the iframe'd page to reload as parent强制 iframe 页面重新加载为父级的最佳 SEO 方式
【发布时间】:2010-08-24 15:35:29
【问题描述】:
<html>
   <iframe src="iWantToBeTheParent.html" />
</html>

我认为这是一个 JavaScript 任务,使用 htaccess 处理重定向会很好,因为我的代码将在 iframe 中,我正在寻找一种从 iframe 源内部启动的方法,这将使 iframe url 加载作为父母。

我只能访问 iframe 源页面的 html。
是否也可以发送 301 HTTP 重定向?

编辑:如果需要,我可以使用 php 将 iframe 页面的 url 作为 JavaScript 变量打印出来。

【问题讨论】:

  • 您是否有权访问 iframe 的源或父级的源?

标签: javascript html http-headers redirect


【解决方案1】:

你可以尝试一些javascript:

<script type="text/javascript">
    <!--
        if (top.location!= self.location) {
            top.location = self.location.href
        }
    //-->
</script>

礼貌: http://usablelayout.com/articles/automatically-break-out-iframe

这会将顶级位置(主页)设置为 javascript 所在页面的位置(在 iframe 内)。

【讨论】:

  • 有谁知道我们是否可以在进行上述重定向时使用 JavaScript 设置 HTTP 标头?
猜你喜欢
  • 1970-01-01
  • 2021-08-02
  • 2023-03-31
  • 1970-01-01
  • 1970-01-01
  • 2010-12-07
  • 2014-08-28
  • 2013-06-22
相关资源
最近更新 更多