history.pushState为什么两次回复问题?

时间:2016-01-20 21:09:44

标签: pushstate html5-history popstate

我喜欢这个代码,当我运行点击功能需要支持2个单位之前页面为什么两次?

jQuery(document).ready(function ($) {
    $('.pager .pages ol li a,#narrow-by-list dd ol li a,.currently ol li a,.actions a').on('click' ,function(event){
        window.history.pushState({page: this.href}, null, this.href);
        $('html, body').animate({
             scrollTop: $("#uppp").offset().top - 60
        }, 1300,'easeInOutExpo');
        // event.preventDefault();              
    });
    $(document).on("scroll mousedown DOMMouseScroll mousewheel keydown", function (e) {
        if (e.which > 0 || e.type === "mousedown" || e.type === "mousewheel") {
            $('html, body').stop();
        }
    });
    window.onpopstate = function(event) {
        var state = event.originalEvent.state;
        window.location.href = document.location;
    };
});

0 个答案:

没有答案