jquery 瀑布流原理 页面到达底部加载数据的方法

来源:互联网 发布:mac电脑自带抠图软件 编辑:程序博客网 时间:2024/05/15 10:55
<html><head>    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js" type="text/javascript"></script>   <script type="text/javascript">                function insertcode() {                    var $body = $("body");                    $body.append('<div style=\" height:1000px; font-size:24px;\">新增项目</div>')                    $("#page_tag_load").hide();                }                $(document).ready(function () {                    $(window).scroll(function () {                        var $body = $("body");                        var $html = "";                        $html += "<br/>" + ($(window).height() + $(window).scrollTop());                        $html += "<br/>window.height: " + $(window).height();                        $html += "<br/>body.height: " + $body.height();                        $html += "<br/>window.scrollTop: " + $(window).scrollTop();                        $("#page_tag_bottom").html($html);                  /*关键 如果 屏幕高度加上 向下滚动距离等于 body 文档高度 或者 大于*/                        if (($(window).height() + $(window).scrollTop()) >= $body.height()) {                            $("#page_tag_load").show();                            //setTimeout(insertcode, 1000);/*IE 不支持*/                            insertcode();                        }                    });                });    </script></head><body>    <div style=" height:1000px; font-size:24px;">新增项目</div>    <div id="page_tag_bottom" style=" width:100%; position:fixed; top:0px; background-color:#cccccc;height:100px;"></div>    <div id="page_tag_load" style=" display:none; font-size:14px;position:fixed; bottom:0px; background-color:#cccccc;height:50px;">加载中...</div></body></html>

0 0
原创粉丝点击