【发布时间】:2012-02-19 21:45:22
【问题描述】:
我在 Firefox 中遇到了 hashchange 事件的问题。我们使用的是 Ben Alman 提供的 JQuery hashchange 插件。代码如下。
$(window).hashchange(function (e) {
alert("Hello");
//we want to perform a post in here.
});
var temp = "#123";
if (temp !== "") {
if (window.location.hash == temp) {
$(window).hashchange();
}
else{
window.location.hash = temp;
}
}
else {
window.location.hash = "#Home/Home";
};
现在这在 IE9 和 Chrome 中运行良好,但是在 Firefox 中,我看到了警报,但只要我单击确定,页面就会刷新,再次显示警报,并无限继续。 Firefox 使用了某种我不知道的奇怪行为吗?还是只是其他一些隐藏得更深的问题?
【问题讨论】:
-
我在 FF 9.0.1 或 10.0.2 中没有这个问题。它显示警报,我点击 OK,然后什么也没有。
-
请将您的解决方案添加为答案,以便人们在未来轻松找到它。
-
会做,只是等待8小时的时间框架过去
标签: javascript jquery hashchange