日期:2014-05-16  浏览次数:20307 次

当滚动条到最底部,自动加载页面,如何实现,类似微博那种
当滚动条到最底部,自动加载页面,如何实现,类似微博那种

参考下面网站
http://www.dzone.com/links/index.html


------解决方案--------------------
查看下源文件
HTML code
<script>
    if(true){
        jQuery(function(){
           var m = window.location.search.match(/p=(\d+)/);
           var curPage = m ? parseInt(m[1]) : 1;
           var loading = false;

           jQuery("#content").scroll(function(){
               if ( curPage >= 1 && !loading && this.scrollHeight -
                       this.scrollTop - this.offsetHeight < this.offsetHeight ) {
                   loading = true;
                   if ((25*curPage) < 79346) {
                        DWRUtil.setValue("scrollStats", 25*(curPage+1) + " of " + 79346);
                    } else {
                        DWRUtil.setValue("scrollStats", 79346);
                    }
                   $("progressIndicator").style.display="block";
                   jQuery.ajax({
                       type: "GET",
                       dataType: "html",
                       url: window.location + (window.location.search != '' ? "&" : "?") + "type=html&p=" + ( ++curPage ),
                       success: function( html ){
                           html = jQuery.trim( html );

                           if ( html ) {
                               jQuery("#content-inner").append( html );
                               
//                             }
                           } else
                               curPage = 0;
                       },
                       complete: function(){
                           loading = false;
//                         alert(window.location.pathname + (window.location.search != '' ? ""+ window.location.search +"&" : "?") + "p=" + ( curPage ))
                           pageTracker._trackPageview(window.location.pathname + (window.location.search != '' ? ""+ window.location.search +"&" : "?") + "p=" + ( curPage ));
                           _qacct="p-ebK_XdQH1HeLo"; quantserve();
                           $("progressIndicator").style.display="none";
                       }
                   });
               }
           });
        });
    }
</script>