我在此代码中使用BBQ历史插件:
$(window).bind( 'hashchange', function(e) {
var url = $.param.fragment();
var new_page = url.replace('.php', '');
if (new_page == 'product') {
var new_page_num = 1;
} else if (new_page == 'installations') {
var new_page_num = 2;
} else if (new_page == 'blog') {
var new_page_num = 3;
} else if (new_page == 'contact') {
var new_page_num = 4;
}
if (new_page_num == cur_page_num) {
return false;
} else if (new_page_num > cur_page_num) {
nextPage();
} else if (new_page_num < cur_page_num) {
previousPage();
}
// Remove class 'current'
$('a.current').removeClass( 'current' );
// Add .current class to "current" nav link(s), only if url isn't empty.
url && $( 'a[href="#' + url + '"]' ).addClass( 'current' );
});
$(window).trigger( 'hashchange' );
在'hashchange'事件中,我想执行此操作:
将当前url(cur_page_num)与下一个url(new_page_num)进行比较并执行 nextPage()或previousPage()函数。
我可以获得下一个网址(var new_page)。
有谁知道我怎么能得到我来自的哈希?
(localhost / #hash1到localhost / #hash2: hash1&lt; hash2所以执行nextPage();,我怎样才能得到hash1?)
谢谢!