强制 iframe 页面作为父页面重新加载的最佳 SEO 方法

发布于 2024-09-15 23:36:01 字数 388 浏览 2 评论 0原文

<html>
   <iframe src="iWantToBeTheParent.html" />
</html>

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

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

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

<html>
   <iframe src="iWantToBeTheParent.html" />
</html>

I think this is a JavaScript task, it would be nice to handle the redirection with htaccess though since my code will inside an iframe I'm looking for a method that initiates from inside the iframe source which would make the iframe url load as the parent.

I only have access to the iframe source page's html.
Would it be possible to send a 301 HTTP redirect as well?

EDIT: I could use php to print out the url of the iframe page as a JavaScript variable if needed.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

◇流星雨 2024-09-22 23:36:01

您可以尝试一些 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 内)。

You could try some javascript:

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

Courtesy of:
http://usablelayout.com/articles/automatically-break-out-iframe

This will set the top level location (the main page) to the location of the page where the javascript is located (inside the iframe).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文