js返回到上個頁面之後,滾動條還在上次的地方

/*返回上次瀏覽的位置*/
        $(function(){
                var str=window.location.href;
                str =str.substring(str.lastIndexOf("/")+1);
                if($.cookie(str)){
                   //幾秒內移動到上次的位置
                $("html,body").animate({scrollTop:$.cookie(str)},500);
                 }else{
                          
                }
        });
        $(window).scroll(function () {
        var str = window.location.href;
        str = str.substring(str.lastIndexOf("/") + 1);
        var top = $(document).scrollTop();
        $.cookie(str, top, { path: '/' });
        return $.cookie(str);
        });

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章