Firefox 奇怪的 iframe 行为

发布于 2024-11-01 11:28:24 字数 304 浏览 7 评论 0原文

我有一个网站,通常将所有内容嵌入 iframe 中。如果您尝试直接通过浏览器访问相同的内容,我们会加载站点框架,并为您在 iframe 中加载该内容(这全部由引用者处理,确定它是内部请求还是外部请求)。

这在 Google Chrome 中工作得很好,但 Firefox 似乎拒绝请求 iframe 中的内容(如果它与父窗口 URL 相同)。这是预期的吗?我可以想象他们这样做是为了防止无限循环,但我在任何地方都找不到它的记录。奇怪的是我可以通过在查询字符串中添加任何其他内容来解决它。当然,我宁愿不必这样做。

如果这是预期的行为,那么我所做的不是一个好主意吗?

I have a site that normally embeds all content in an iframe. If you were to try to access the same content directly through the browser, we load the site framework and instead load that content in the iframe for you (this is all handled by referer determining if it's an internal or external request).

This works just fine in Google Chrome, but Firefox seems to refuse to request content in an iframe if it's the same as the parent window URL. Is this expected? I could imagine them doing this to prevent infinite loops, but I can't find it documented anywhere. The strange part is I can work around it by adding anything additional to the query string. Of course, I'd prefer not to have to do this.

And if this is expected behavior, is what I'm doing not such a good idea?

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

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

发布评论

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

评论(1

这个俗人 2024-11-08 11:28:24

一般来说,使用 iFrame 并不是最热门的计划,但它可能是合理的。不过,Firefox 的行为是可以预料的。您的两个选择是:

1) 当您检测到用户单独加载内部框架时,重定向(通过 HTTP-HEADER)到父页面并使用查询字符串告诉该页面要加载什么内部框架。

2)做你现在正在做的事情,并添加一个充满随机数据的查询字符串(&framebuster=231784783243253426543)以使事情保持良好和独立。

Using iFrames is in general not the hottest plan, but it may be justified. Firefox's behavior is to be expected, however. Your two options are:

1) When you detect a user loading an inner frame alone, redirect (via HTTP-HEADER) to the parent page and use a query string to tell that page what inner frame to load.

2) Do what you're doing now, and add a query string full of random data (&framebuster=231784783243253426543) to keep things nice and separate.

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