将锚点保存在ie6历史记录中 [英] Save the anchor in the ie6 history

查看:91
本文介绍了将锚点保存在ie6历史记录中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有锚导航的网站(比如gmail,当锚值更改时,页面的新内容加载了ajax)。在Firefox中,当我更改锚点(使用js或页面)时,会创建历史记录中的新项目并且可以正常运行。但是在IE6中它没有存储这个新项目,并且后退按钮不能按预期工作。

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.

无论如何使用javascript添加这个新项目?
这是可能的,因为gmail会这样做,但我不知道它是怎么做的。

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.

推荐答案

我是用历史记录和使用哈希完成很多的工作。几乎所有现有的历史插件都有一些差距。我使用的那个非常接近完美的是这个jQuery插件:

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

它在今年3月更新处理IE 8问题,它也非常成功地处理IE6。我注意到的一件事是IE真的讨厌吗?在#之后的哈希中。它何时停止正确处理哈希?存在。即便是这个我认为需要一点补丁?我真的需要把它发送给Mikage。处理此问题的方法是在引用哈希时在插件中使用 location.hash ,而不是使用此函数:

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 "";
}

因此,在需要散列的那些地方,传递 location to to function ...

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

 getHash(location) 

...而不是使用location.href。但请注意,对于IE,因为它使用iframe,您想要使用iframe.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)

雅虎的错误

在查看此URL时,您可以看到Yahoo在IE中没有优雅处理?

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

它应该忽略不存在的模块(它对其他没有?的模块有效)他们)。但是当它出现时会引发JavaScript错误?在网址中。

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)

真的很简单历史

坦率地说,它的主要问题似乎是它处于休眠状态。我已经体验过这个问题,只是不想要挖掘它:

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:


此外,即使
没有变化,我也会在页面上进行
在历史记录的后面,后面的
功能将在我使用RSH之前在
之前导航
的页面时返回。所以,如果我在
点击RSH页面中的四个链接,
后退功能将在
之后返回我点击了后退按钮4
次。我希望这是有道理的。

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.

这篇关于将锚点保存在ie6历史记录中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆