This page is part of a full example. If you didn't see a "step 1", click here to reset!

2 Click these links to change the Iframe location.hash: #middle and #end.

The location.hash should go from #begin → #middle → #end as you click the links above.

The current Iframe location.hash is:

Now, in most modern browsers (not IE6 or 7), in an Iframe or not, each hash change creates a new history entry, so that the back button becomes enabled and you can press it to return to a previous entry.

3 After clicking #middle and #end, press the back button twice.

The location.hash should go from #end → #middle → #begin as you press the back button

When the #middle or #end links are clicked, and the location.hash is changed, the back button should be enabled. In Firefox, IE8 and Opera this works as expected. In Safari and Chrome, in an Iframe, the back button stays disabled.. and in the latest WebKit nightly (r51669), the back button is enabled, but only partially.

For whatever reason, when the location.hash is changed inside an Iframe in Safari or Chrome, no new history entries are created (and the back button stays disabled). In the latest WebKit nightly, new history entries are created, but not for the initial location.hash. Meaning you can go back, but never to #begin.

4 Click here to load this page in the "top" and you'll see that everything works as-expected. Repeat steps 2 and 3 there, and you'll see that the location.hash goes from #begin → #middle → #end → #middle → #begin. When you're done, press the back button again to return to the "in an Iframe" page.

5 Now that you've returned to the "in an Iframe" page, repeat steps 2 and 3 a final time.. and see that the history now works! Well, almost works, because you still can't get to the initial #begin location.hash in Safari, Chrome, or the WebKit nightly.

What's up with that, WebKit?

The code

$(function(){
  
  // Show the current location.hash.
  setInterval(function(){ $('#status').text( location.hash ); }, 100);
  
});