当前位置 : 主页 > 网络编程 > JavaScript >

history ajax

来源:互联网 收集:自由互联 发布时间:2021-06-30
history ajax 回退历史 function setState(p) { var list = ''; if ($('.goods-list')) { list = $('.goods-list'); } else if ($('.first-list')) { list = $('.goods-list'); } else if ($('.ads-list')) { list = $('.ads-list'); } else { } var stat
history ajax 回退历史
function setState(p) {
    var list = '';
    if ($('.goods-list')) {
        list = $('.goods-list');
    } else if ($('.first-list')) {
        list = $('.goods-list');
    } else if ($('.ads-list')) {
        list = $('.ads-list');
    } else {

    }
    var statusUrl = window.location.href;
    var stateobj = ({
        //里面存放url等信息,stateobj将作为pushState()的第一个参数
        url: statusUrl,
        list: list.html(),
        title: '',
        page: p
    });
    if (window.history.state) {
        window.history.replaceState(stateobj, null, statusUrl); //将当前url加入堆栈中
    } else {
        window.history.pushState(stateobj, null, statusUrl); //将当前url加入堆栈中
    }
};
function aClick() {
    $('a').click(
        function (event) {
            event.preventDefault();
            if ($('.goods-list')) {
                var page = $('.goods-list').data('page');
            } else {
                var page = 0;
            }


            if (!$(this).hasClass('tb_app')) {
                setState(page);
            }

            var cms_ua = navigator.userAgent.toLowerCase();
            if ($(this).hasClass('ui-link') && cms_ua.match(/MicroMessenger/i) == 'micromessenger') {} else {
                window.location.href = $(this).attr('href');
            }
        }
    )
}
引用
if(window.history.state){
                                $('.goods-list').html(window.history.state.list);
                                var p = window.history.state.page;
                            }else{
                                var p = 2;
                            }
上一篇:vscode setting
下一篇:webpage-skipping
网友评论