我尝试过BBQ和history.pushstate,但两者都有问题。在history.pushstate和using bbq
的堆栈中查看我的其他问题使用此代码,我基本上在特定div中加载内容,每次单击链接时替换旧内容。我正在尝试在加载内容时更改浏览器地址,并且能够点击浏览器本身的后退或上一个按钮来重新加载内容
divheight = $(".heightDiv").innerHeight();
container = $(".loadContent");
currentItem = null;
$(".list-group a").each(function () {
var item = $(this);
if (item.hasClass("active")) {
currentItem = item;
}
item.on("click", function() {
$(".heightDiv").css("height", divheight);
if (currentItem == item) return;
$(".content").empty();
$(".loading").css("height", divheight).show();
url = this.href + " .content";
if (currentItem) currentItem.removeClass("active");
currentItem = item.addClass("active");
container.load(url, function() {
$(".loading").hide();
});
});
});