html - 为什么没有为与页面相同的 url 加载 iframe

标签 html iframe

我只是在测试一些东西,遇到了有趣的 iframe 行为。 在我的页面上有以下 iframe:

<iframe src="/Wizard/Start"></iframe>

现在,如果 iframesrc 与页面 (.../Wizard/Start) 的 url 相同,则iframe 不加载内容,只是保持空白并且没有错误、警告或任何报告。

我可以看出这是设计使然,在所有浏览器中都一样。

为什么?有关此行为的任何官方文档吗?

最佳答案

这确实是指定的行为。您的问题的答案在本文档中:

http://www.w3.org/TR/WD-frames-970331

在“无限递归”部分,它说:

Infinite recursion is prevented. Any frame that attempts to assign as its SRC a URL used by any of its ancestors is treated as if it has no SRC URL at all (basically a blank frame). This doesn't prevent all malicious documents, but it eliminates a troublesome class of them.

该文档可以追溯到 1997 年,但据我所知尚未被取代。

关于html - 为什么没有为与页面相同的 url 加载 iframe,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22126190/

相关文章:

javascript - 始终获取 Json 中每个文件的最后一个 ID

javascript - 使用 Grails 在执行警报的事件处理程序中转义双引号

javascript - getSelection 不适用于 Chrome 中的图像

php - div 内的段落与 parsedown

html - 长除号(HTML 和/或 CSS)

javascript - 在流中传递 ID3 信息并在前端进行解析

css - 抑制加载页面时在 IE6 中的 iFrame 中强制水平滚动

javascript - FireFox 的父级 iframe 不起作用?

javascript - 从同一域的 iframe 中的元素获取值

javascript - iframe 再次下载字体文件,尽管它是在主文档中下载的