Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/465.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript history.pushstate jquery后退按钮未加载上一个内容_Javascript_Jquery_Browser History - Fatal编程技术网

Javascript history.pushstate jquery后退按钮未加载上一个内容

Javascript history.pushstate jquery后退按钮未加载上一个内容,javascript,jquery,browser-history,Javascript,Jquery,Browser History,我正在努力 这是我拥有的以下代码: container = $(".loadContent"); currentItem = null; $(".list-group a").each(function (index) { var item = $(this); if (item.hasClass("active")) { currentItem = item; } item.on("click", function(e) { e.

我正在努力

这是我拥有的以下代码:

container = $(".loadContent");
currentItem = null;
$(".list-group a").each(function (index) {
    var item = $(this);
    if (item.hasClass("active")) {
        currentItem = item;
    }
    item.on("click", function(e) {
        e.preventDefault();
        history.pushState({}, '', $(this).attr("href"));
        $(".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();});
        return false;
    });
});

loadPage = function(href) {
  container.load(href + " .content");
};

$(window).on("popstate", function(e) {
  if (e.originalEvent.state !== null) {
    loadPage(location.href);
  }
});
地址栏正在拾取正确的地址,但是,当我按下后退按钮时,地址栏会正确返回,但未加载以前的内容