我只是在测试一些东西,遇到了有趣的 iframe
行为。
在我的页面上有以下 iframe
:
<iframe src="/Wizard/Start"></iframe>
现在,如果 iframe
的 src
与页面 (.../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/