• JS 判断滚动底部并加载更多效果。。。。。。。。。


    JS 判断滚动底部并加载更多效果。。。。。。。。。

    <html lang="zh-cn">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>js网页滚动条滚动事件 </title>
    <style type="text/css"> 
    #top_div{ 
        position:fixed; 
        bottom:80px; 
        right:0; 
        display:none; 
    } 
    </style> 
    
    <script type="text/javascript"> 
    
    window.onscroll = function(){ 
        var t = document.documentElement.scrollTop || document.body.scrollTop;  
        var top_div = document.getElementById( "top_div" ); 
        var loading = document.getElementById("loading"); 
    
              vv.innerHTML="document.body.scrollHeight:"+document.body.scrollHeight+" body offsetHeight:"+document.body.offsetHeight;
            //scrollTop + clientHeight == scrollHeight
    
        if( document.body.scrollTop+ document.body.clientHeight >= document.body.scrollHeight) { 
    
            top_div.style.display = "inline"; 
            if(loading.style.display != "inline"){
    
                 loading.style.display = "inline";
                 count.value=(1+ parseInt(count.value));
                 setTimeout("addItem(count.value);",2000);
             }
        } 
    
    
    } 
    
    
     function addItem(i){
    
       for(var j=0;j<10;j++){
        var box = document.createElement("div"); 
    		content.appendChild(box);
    		box.style.cssText = "300px;font-size:12px;";
                    box.innerHTML="<a href='#'>..........."+ i+"</a>"
    
    
           }
    
           loading.style.display = "none";
    
       }
    
    
    
    </script> 
    
    
    </head>
    <body>
    
    
    <div id="vv"></div> 
    
    <br /> 
    
    <a name="top">顶部<a> 
    
    <div id="top_div"><a href="#top">返回顶部</a></div> 
    
    <br /> 
    
    <div id="content">
    
    <a href="#">...........</a>
    
    
    </div> 
    
    <br /> 
    
    这里尽量多些<br />以便页面出现滚动条
    
    
    <br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />
    
    
    <div id="loading" style="position:fixed;bottom:20px;line-height:40px;background-color: #F00;color: #fff; display:none;">
      loaing............................................................................................................<input id="count" type='text' value="0"/>
    </div>
    
    
    </body>
    </html>
    

      

  • 相关阅读:
    winform中利用正则表达式得到有效的电话/手机号
    winform运行时如何接受参数?(示例)
    [基础]Javascript中的继承示例代码
    [转]C#中"is" vs "as"
    Javascript数组常用方法[包含MS AJAX.NET的prototype扩展方法]示例
    linq学习笔记(一)
    用winform应用程序登录网站的解决方案
    [转贴]操纵自如--页面内的配合与通信
    .net3.0中的扩展方法(示例)
    window.location或window.open如何指定target?
  • 原文地址:https://www.cnblogs.com/wgscd/p/4689067.html
Copyright © 2020-2023  润新知