Save the anchor in the ie6 history

internet-explorer, javascript

Solution

I've done a lot of work with history and using the hash. Almost all of the existing history plugins have some sort of gap in them. The one I've used that's pretty close to perfect is this one which is a jQuery plugin:

http://www.mikage.to/jquery/jquery.history.js

It was updated in March of this year handles IE 8 issues and it also deals with IE6 pretty successfully. One thing I've noticed is that IE really hates having ? in the hash after the #. It stops properly handling the hash when the ? is present. Even this one I think needs a little patch for the ?, I really need to send that along to Mikage. The way to handle this is instead of using `location.hash` in the plugin when referencing the hash, use this function:

function getHash(loc) {
    loc = loc.toString();
    if (loc.indexOf("#") != -1)
        return loc.substring(loc.indexOf("#"));
        else return "";
}

So in those spots where you need the hash, pass `location` the to function...

 getHash(location) 

...instead of using location.href. But note that for IE, because it's using the iframe, you want to use iframe.location instead.

 getHash(iframe.location)

Yahoo's Bug

You can see that Yahoo doesn't gracefully handle ?'s in IE when looking at this URL:

http://developer.yahoo.com/yui/examples/history/history-tabview.html#tabview=tab1?7236471234

It should just ignore the non-existent module, (which it does for other names which have no ?'s in them). But it raises a JavaScript error when a ? is in the URL.

(I will extend this list in a moment)

Really Simply History

Frankly, it's primary issue seems to be it's gone dormant. I've experienced this issue and just didn't want to dig through it:

Also, even though no changes appear to take place on the page while I travel backward through the history, the back functionality will return once I hit the pages that I had been navigating before the one using RSH. So, if I clicked on four links in the RSH page, back functionality will return after I have clicked on the back button four times. I hope that makes sense.

Problem

I have a site with anchor navigation (like gmail, when the anchor value changes a new content for a page is loaded with ajax). In Firefox, when I change the anchor (with js or with a page) a new item in the history is created and works perfectly. But in IE6 it doesn't stores this new item and the back button doesn't work as expected. Is there anyway to add this new item using javascript? This is possible because gmail does it but I don't know how it does it.

Original source