当前位置:网站首页>Native JS implements page scroll bar loading data and page drop-down loading content
Native JS implements page scroll bar loading data and page drop-down loading content
2022-06-27 10:39:00 【Cut potatoes into shreds】
One 、 Preface
Today's case is Scroll bar events , When the distance between the scroll bar and the bottom is less than a range value , Will automatically increase the height of the page , So as to achieve the effect of never drawing to the bottom .
Two 、scrollHeight、scrollTop and clientHeight The difference between
Full text height of web page
Distance from the top of the scroll bar ( The distance the scroll bar is rolled away )
The height of the screen you can see
because js They didn't give it to us The distance of the scroll bar from the bottom We need to calculate by ourselves use Full text height of web page subtract Distance from the top of the scroll bar Subtract the height of the screen you can see to get The distance of the scroll bar from the bottom 了 .
3、 ... and 、 Code
<style>
body{
padding-top: 2000px;
}
</style>
<body>
<script>
var body1 = document.getElementsByTagName("body")[0];
var step = 500;
var offsetx =0;
console.log(body1);
// body1.style.paddingBottom = 0;
// body1.style.paddingBottom =offsetx;
window.onscroll = function(){
// The full text of the web page is high
var pageHeight = document.documentElement.scrollHeight;
// The distance the scroll bar is rolled away
var stop = document.documentElement.scrollTop;
// The height of the screen you can see
var seeHeight = document.documentElement.clientHeight;
// Distance from the bottom
var bottom1 = pageHeight - stop - seeHeight;
// console.log(" Distance from the bottom "+ bottom1)
// console.log(" The full text of the web page is high "+pageHeight)
// console.log(" The distance the scroll bar is rolled away "+stop)
// console.log(" The height of the screen you can see "+seeHeight)
// console.log("---------")
// When the scroll bar is less than... From the bottom 200 It's triggered when
if(bottom1<=200){
offsetx+=step;
body1.style.paddingBottom = offsetx +"px";
// alert(" load ")
// document.write('111111111111111111111111')
}
//console.log(e)
}
</script>This is recorded for future use , I also hope the big guys can communicate more , Leave more messages , Point out my shortcomings !
You can study it if you need it !!
边栏推荐
- 【TcaplusDB知识库】TcaplusDB机型管理介绍
- Tcp/ip explanation (version 2) notes / 3 link layer / 3.4 bridge and switch / 3.4.1 spanning tree protocol (STP)
- File name setting causes an error to be written to writelines: oserror: [errno 22] invalid argument
- Analysis of mobile ar implementation based on edge computing (Part 2)
- 软交换呼叫中心系统的支撑系统
- 并发,并行,异步,同步,多线程,互斥的概念
- 三层架构中,数据库的设计在哪一层实现,不是在数据存储层吗?
- [从零开始学习FPGA编程-47]:视野篇 - 第三代半导体技术现状与发展趋势
- KDD 2022 | 基于分层图扩散学习的癫痫波预测
- Evolution of software system architecture
猜你喜欢

居家办公竟比去公司上班还累? | 社区征文

audiotrack与audioflinger

In the three-tier architecture, at which layer is the database design implemented, not at the data storage layer?

如何在 Methodot 中部署 JupyterLab?

Product strength benchmarking seal /model 3, with 179800 pre-sales of Chang'an dark blue sl03
![[tcapulusdb knowledge base] Introduction to tmonitor background one click installation (I)](/img/0a/3eae294b335c120c4aabd05e4230c3.png)
[tcapulusdb knowledge base] Introduction to tmonitor background one click installation (I)
![[tcapulusdb knowledge base] tcapulusdb tmonitor module architecture introduction](/img/85/39e54ebc613f6d1dc7f02168adaaee.png)
[tcapulusdb knowledge base] tcapulusdb tmonitor module architecture introduction

Record in detail the implementation of yolact instance segmentation ncnn

直播電子商務應用程序開發需要什麼基本功能?未來發展前景如何?

Glide缓存机制
随机推荐
audiotrack与audioflinger
NVME2.0协议——新特性
片刻喘息,美国电子烟巨头禁令推迟,可暂时继续在美销售产品
【云享新鲜】社区周刊·Vol.68-华为云招募工业智能领域合作伙伴,强力扶持+商业变现
【TcaplusDB知识库】Tmonitor后台一键安装介绍(二)
Dimitt's law
JS all network request modes
flutter 微信分享
Metadata of database
并发,并行,异步,同步,多线程,互斥的概念
border影响父元素的高度-解决方案
【TcaplusDB知识库】TcaplusDB机器初始化和上架介绍
Red envelope rain: a wonderful encounter between redis and Lua
. Net
“全班29人24人成功读研”冲上热搜!剩下的5个人去哪了?
On anchors in object detection
直播电子商务应用程序开发需要什么基本功能?未来发展前景如何?
Test how students participate in codereview
Future & CompletionService
CPU design (single cycle and pipeline)