Mobile app version of vmapp.org
Login or Join
Sent6035632

: Firefox, iframes and redirects I encountered this same behavior years ago and gave up back then when I couldn't find a solution. I'm hoping someone knows what's going on here and how to solve

@Sent6035632

Posted in: #Firefox #Html #Iframe

I encountered this same behavior years ago and gave up back then when I couldn't find a solution. I'm hoping someone knows what's going on here and how to solve it.

I have found that if you have a page in Firefox that contains an iframe and in that iframe you load a sub-page that redirects to a second sub-page, you will never see the first sub-page again if you hit "reload/refresh". The only way to see the first sub-page again is to close the window/tab and reopen the parent page. It seems that if you reload a page Firefox will always jump straight to the second sub-page every time. This happens even if you subsequently change the initial iframe URL in the parent document. And this even happens if you change the URL and clear your cache.

When I encountered this problem before, it was causing issues with our ad serving, but this time it's a content issue. Has anyone encountered this themselves and know a way around it?



[EDIT]

I've created thee files you can use to test the iframe behavior, but you'll need to work with an html page of your own on web server you control so you can make changes and test behavior.

The files I'm using are:

www.fatfx.com/tests/doc1.html -- this redirects to doc2.html after 5 seconds www.fatfx.com/tests/doc2.html -- static file www.fatfx.com/tests/doc2.html -- static file


Instructions:


Create an HTML document and put this in its body:
<iframe src="http://www.fatfx.com/tests/doc1.html" width="300" height="300" />
Load in Firefox. You should see This is document one. Redirecting in 5 seconds... and then This is document two.
Hit 'Reload'. You should see immediately This is document two.
Clear you cache and hit 'Reload'. You should see immediately This is document two.
Edit your document and change the URL from doc1.html to doc3.html.
Clear your cache and hit "Reload" in Firefox. You should STILL immediately see This is document two. Check your page source to confirm your code change from step 5 is there.


Notes:
I've tried altering the iframe tag by adding a unique ID; that didn't work. I've tried adding Cache-Control, Pragma and Expires meta tags to prevent document caching; that didn't work. I've tried writing out the tags programatically in JS; that didn't work.

As I say, I encountered this behavior probably three years ago. This can't be a 'bug' but a desired behavior. But there must be some way around it.



Edit 2

It appears this is a known bug with Mozilla, first logged in 2005. It reportedly has been patched in FF4.0, though I can't confirm personally as I haven't loaded this yet on my own machine. The Bugzilla report can be found here.

If anyone does know of a work-around, please let me know and I'll mark this as answered.

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Sent6035632

1 Comments

Sorted by latest first Latest Oldest Best

 

@Speyer207

Easiest way to solve this would be to add:

for each (iframe in document.getElementsByTagName('iframe')) { iframe.src = iframe.src };

to an onload/pre-onload Javascript block.

This would solve the issue even if it existed on other browsers.

Wrap it in a try/catch if you want it to silently fail on older versions of IE (which don't need this fix anyway).

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme