设置window.location.hash的潜在问题 [英] Potential problems setting window.location.hash

查看:187
本文介绍了设置window.location.hash的潜在问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些javascript代码,一次,将 window.location.hash 设置为一个特定的字符串。这在Firefox 3中工作正常,但我想知道我以后是否会遇到这个问题,即这是一个跨浏览器解决方案(包括IE6)?

I have some javascript code which, at one point, sets window.location.hash to a specific string. This works fine in Firefox 3, but I want to know if I will run into problems with this later, i.e. is this a cross-browser solution (IE6 included)?

此外,我使用ReallySimpleHistory。

Also, I am using ReallySimpleHistory. Will this mess up its internal state?

感谢

推荐答案

code> window.location.hash 自从1995年在Netscape Navigator 2中引入JavaScript以来,它在1996年首次被Internet Explorer 3支持。我认为你可以可以合理地确定每个支持JS的浏览器都支持它。

window.location.hash has been around since JavaScript was introduced in Netscape Navigator 2 back in 1995. It was first supported by Microsoft in Internet Explorer 3 in 1996. I think you can be reasonably certain that every JS-capable browser supports it.

从源代码中快速浏览,看起来好像ReallySimpleHistory非常广泛地使用这个属性,所以你可以打破它。您可能想使用 add(newLocation)方法(通过设置 window.location.hash )。

From a quick glance through the source, it looks as if ReallySimpleHistory makes pretty extensive use of this property, so you may well break it. You might want to use its add(newLocation) method instead (which works by setting window.location.hash).

这篇关于设置window.location.hash的潜在问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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