【发布时间】:2011-03-06 16:48:29
【问题描述】:
首先,我要感谢大家阅读本文并回答我的问题。迄今为止所提供的帮助非常宝贵,感谢所提供的帮助,我成为了一名更好的程序员。
到手头的问题。我担心这有点粗糙,但下面的脚本大部分都有效。
问题在于,虽然历史记录被存储,但当用户返回或前进时,页面并没有改变。你知道我可以做些什么来修改它以便触发 go 函数吗?
$(document).ready(function(){
$("a").click(function() {
if (strpos($(this).attr('href'), 'mob.php') !== false) {
window.location = url($(this).attr('href'));
go(idToPath($(this).attr('href')));
return false;
}
});
});
function go(num) {
if (num != undefined) {
$.ajax({
url: "mob.php?p="+num+"&logo=0",
cache: false,
success: function(html){
$("#ajax").html(html);
}
});
}
}
$.history.init(function(u) {});
var page = 4;
var id = window.location.hash.substr(1);
if (id != '' && page != id) {
go(id);
}
【问题讨论】:
标签: jquery ajax browser-state