Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

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:

  1. http://www.fatfx.com/tests/doc1.html -- this redirects to doc2.html after 5 seconds
  2. http://www.fatfx.com/tests/doc2.html -- static file
  3. http://www.fatfx.com/tests/doc2.html -- static file

Instructions:

  1. Create an HTML document and put this in its body: <iframe src="http://www.fatfx.com/tests/doc1.html" width="300" height="300" />
  2. Load in Firefox. You should see This is document one. Redirecting in 5 seconds... and then This is document two.
  3. Hit 'Reload'. You should see immediately This is document two.
  4. Clear you cache and hit 'Reload'. You should see immediately This is document two.
  5. Edit your document and change the URL from doc1.html to doc3.html.
  6. 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.

share|improve this question
    
Can you post a test case? –  John Conde Apr 6 '11 at 0:50
    
@Andrew: Just a heads up that unless you put the users exact name in a reply the user does not get a ping about the comment, unless it's their question/answer; very likely you know this, but can't tell. Cheers! CC: John Conde –  blunders Apr 6 '11 at 2:08
    
@blunders: Ah. Interesting. I didn't know (and I've been posting to SO for ages). I will delete my comment above and repost. –  Andrew Apr 6 '11 at 2:13
    
@John Conde: I've added instructions on reproducing this issue. It does seem to be a reported bug in Bugzilla, but since this is so old, I'm hoping someone's figured out a way to get around this. –  Andrew Apr 6 '11 at 2:15
    
+1 for the content of fatfx.com , though it's a little low contrast (in google chrome). –  Kzqai Apr 6 '11 at 16:20

1 Answer 1

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).

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.