js 窗口滚动到一定高度时加载数据
2015-03-11 16:25
369 查看
<script type="text/javascript"> //当窗口滚动到一定高度时 某块页面开始加载数据 window.onload = function() { var oHeader = document.getElementById("header"); var height = oHeader.offsetHeight; window.onscroll = function(){ //scrollTop的值 var scrollTop = document.documentElement.scrollTop || document.body.scrollTop; //窗口可视化高度 var clientHeight = document.documentElement.clientHeight || document.body.clientHeight; document.getElementById("txt1").value="scrollTop:"+scrollTop+",height:"+height; var oContent = document.getElementById("content"); if(scrollTop+clientHeight >height) { oContent.innerHTML = "<h1>正在加载中.....</h1>"; //延迟3秒执行 setTimeout(function(){ oContent.innerHTML = "<h1>scroll事件执行的代码块</h1>"; oContent.style.background="red"; },3000); } else { oContent.innerHTML=""; oContent.removeAttribute("style"); } } } </script>
相关文章推荐
- js获取窗口可视范围的高度、获取窗口滚动条高度、文档内容实际高度
- 使用jQuery或者原生js实现鼠标滚动加载页面新数据
- js中滚动鼠标加载数据
- js刷新窗口 (父窗口,以及点确定后的当前窗口) 一般用于页面数据刷新重新加载
- js中对arry数组的各种操作小结 瀑布流AJAX无刷新加载数据列表--当页面滚动到Id时再继续加载数据 web前端url传递值 js加密解密 HTML中让表单input等文本框为只读不可编辑的方法 js监听用户的键盘敲击事件,兼容各大主流浏览器 HTML特殊字符
- js 下拉底部加载|滑轮滚动到页面底部ajax加载数据的实例
- js窗体滚动加载数据事件
- js滚动分页加载数据
- js页面滚动到底部时自动加载下一页数据
- 使用jQuery或者原生js实现鼠标滚动加载页面新数据
- js/jquery获取浏览器窗口的可视区域高度和宽度,滚动条高度
- vue.js中滚动条加载更多数据
- js实现滚动到页面底端加载下一页数据
- 浏览器窗口滚动加载数据采用异步形式从后台加载数据
- JS实现div随屏幕滚动到一定高度后固定
- js 鼠标滚动到某屏时,加载那一屏的数据,仿京东首页楼层异步加载模式
- js实现滚动条边滚动边加载数据
- js滚动异步加载数据的思路
- JS滚动加载数据的方法
- 浏览器窗口滚动加载数据