【发布时间】:2012-10-15 11:14:00
【问题描述】:
我的问题类似于this one,但我的问题不在 IE(未测试)中,而是在 Chrome 和 Firefox 中。无论如何,这个问题没有答案。
我正在使用BBQ plugin,代码如下:
$(window).bind('hashchange', function(e) {
var href = $.param.fragment();
hrefOld = $("#loadZone").attr("src");
centerZoneActivePage = href;
// Create container for this url's content and store a reference to it in
// the cache.
cache[ href ] = $("#loadZone").attr("src", href);
alert("new: " +href);
});
// Since the event is only triggered when the hash changes, we need to trigger
// the event now, to handle the hash the page may have loaded with.
$(window).trigger( 'hashchange' );
发生的情况是,当我在 iframe(“#loadZone”)中加载新页面时,哈希值正在正确更改。但是当我点击浏览器后退按钮时,前一页正在加载,但没有改变哈希。当第二次点击时,hash 改变并且活动页面保持在 iframe 中。我不明白为什么哈希在第一次没有改变,因为上一页加载。
注意:警告信息仅在第二次点击返回按钮时出现。
返回按钮点击总结:
- 首次点击:Iframe 上一页已加载,未显示警报消息,哈希未更改;
- 第二次点击:Iframe 页面还是一样,提示信息显示,hash 改变了。
如何同步? 我正在使用 jquery-1.7.1.js。有人用过这个版本的BBQ插件,成功了吗?我读过this question,但还没有定论。
【问题讨论】:
标签: jquery jquery-plugins browser-history jquery-bbq