Why iframe is not loaded for same url as page

强颜欢笑 提交于 2019-12-22 04:55:36

问题


I was just testing some stuff and came across the interesting iframe behavior. On the page i have the following iframe:

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

Now, if the src of iframe is the same as url of the page (.../Wizard/Start), the iframe does not load the contents, just remains blank and there is no errors, warnings or anything reported.

I can see that this is by design, acts the same in all browsers.

Why? Any official documentation on this behavior?


回答1:


This is indeed the specified behaviour. The answer to your question is in this document:

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

In the section "Infinite Recursion" it says:

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.

The document dates back to 1997 but hasn't been superseded yet, as far as I know.




回答2:


you mean you are loading the iframe of "abc" page of abc page??

_____________________
|                    |
|      IFrame        |
---------------------|
|                    |
|       Page         |
|                    |
_____________________

and here iframe again pointing to the same page right?? see it will not work as it become the infinite loop..

you are trying to load the same page in iframe.. mean the content of iframe again contains another iframe which again pointing to the same page which again has the iframe.. so it will be infinite loop and thats why it will not work..

on page "xyz" you can include the iframe of "abc", it will not be a problem



来源:https://stackoverflow.com/questions/22126190/why-iframe-is-not-loaded-for-same-url-as-page

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!