Shashank Jain
Shashank Jain

Reputation: 857

Iframe within Iframe not supported?

I just got a thought and made an html page with an iframe pointing to same page. So, it should have kind of generated an infinite loop. But, it didn't. So can anyone explain the output?

test.html
<iframe width="600" height="500" src="http://localhost/test.html"></iframe>

Hello World!

Upvotes: 0

Views: 292

Answers (3)

Falcon
Falcon

Reputation: 1367

I thought of this as well! and I made a demo of it: http://blog.falcondai.com/2012/09/infinite-iframe-demo.html

Modern browsers has url-based loop detection but it can easily worked around by changing the url a bit and returning the same thing on the server side. Firefox which has a hard limit of rendering at most 10 nested frames, is resistant to such abuse.

Upvotes: 0

Shadow Wizard
Shadow Wizard

Reputation: 66399

For me, IE9 and Firefox (latest) both showed empty frame and Chrome showed frame with "Hello World!" as well.

So I would say that IE9 and Firefox (meaning Trident and Gecko engines) simply ignore frames referencing themselves treating them as invalid (though I couldn't find any warning) while Chrome (meaning WebKit engine) parse it only once, avoiding the infinite loop in the most elegant way.

Upvotes: 0

user142019
user142019

Reputation:

Browsers aren't dumb. They prevent this from happening, otherwise your computer will crash (insufficient memory available).

Upvotes: 1

Related Questions