Thursday, August 25th, 2005

Ajax Tutorial: A Tale of Two IFrames

Category: Articles

Brad Neuberg has written a mini-tutorial on the black art of iframes and browser history.

iframes? er we get that… you may think. However, Brad gets into the differences between:

simple iframe via markup

<iframe id=”testFrame” src=””>

iframe programatically

var testFrame = document.createElement(“IFRAME”); = “testFrame”;
testFrame.src = “”;

Thoughts on browsers

In Firefox:

  • If the iframe is inside the HTML and was loaded in the page, any location changes to it are stored in the browser’s history.
  • If the iframe was written into the DOM after the page was finished loading through JavaScript, then no location changes are stored in the browser’s history.

In Internet Explorer:

  • Both kinds of iframes store their location changes into the browser’s history.

In Safari:

  • Neither kind of iframe stores its location changes into the browser’s history.

Posted by Dion Almaer at 10:27 am
1 Comment

3.6 rating from 9 votes

1 Comment »

Comments feed


I am using an iframe in a file upload program (yes, another photo album) and am having a problem… very apt to this discussion:

Every file upload I do creates a history entry in my browser, breaking the back button (the reverse of the normal problem).

Is there a way to do a file upload with iframes without the history being messed up??


Comment by Brad Broerman — October 22, 2007

Leave a comment

You must be logged in to post a comment.