javascript - Save the anchor in the ie6 history - Stack Overflow

I have a site with anchor navigation (like gmail, when the anchor value changes a new content for a pag

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.

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.

Share edited Jun 5, 2009 at 13:03 Luiz Guilherme asked Jun 5, 2009 at 12:56 Luiz GuilhermeLuiz Guilherme 1,6211 gold badge21 silver badges37 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 9

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

I think you may have a different problem. IE6 certainly handles # links in history as it should for me on any given test page, so I believe either you have broken this in some way or you have a bug with your particular version of IE.

I suggest you try a few different copies and versions of IE6 on other machines to rule out the latter, and then try simplifying your code and rebuilding it to see if and when the problem appears. Turning off JS may (html depending) be a fast way to test this.

If all else fails I suggest you look at Really Simple History which (last time I checked) solves almost all JS/history problems you can throw at it.

Yahoo has a history manager too.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745049597a4608304.html

相关推荐

  • javascript - Save the anchor in the ie6 history - Stack Overflow

    I have a site with anchor navigation (like gmail, when the anchor value changes a new content for a pag

    9小时前
    40

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信