The editor below will share with you a simple example based on scroll bar position judgment. The power of JavaScript is obvious to all, so you can learn JavaScript## well. How important # is, friends who are interested in JavaScript, please follow the editor to have a look
The example is as follows:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | function getScrollTop() {
var scrollTop = 0;
if (document.documentElement && document.documentElement.scrollTop) {
scrollTop = document.documentElement.scrollTop;
} else if (document.body) {
scrollTop = document.body.scrollTop;
}
return scrollTop;
}
function getClientHeight() {
var clientHeight = 0;
if (document.body.clientHeight && document.documentElement.clientHeight) {
clientHeight = Math.min(document.body.clientHeight, document.documentElement.clientHeight);
} else {
clientHeight = Math.max(document.body.clientHeight, document.documentElement.clientHeight);
}
return clientHeight;
}
function getScrollHeight() {
return Math.max(document.body.scrollHeight, document.documentElement.scrollHeight);
}
getScrollTop() + getClientHeight() == getScrollHeight()
|
Copy after login
The above simple example based on scroll bar position judgment is all the content shared by the editor. I hope it can To give you a reference, I also hope that everyone will support the PHP Chinese website.
Related recommendations:
js scroll bar multiple styles, recommended_javascript skills
js scroll bar back to top code_javascript skills
js scroll bar smooth movement sample code_javascript skills
The above is the detailed content of Simple example based on scroll bar position judgment_javascript skills. For more information, please follow other related articles on the PHP Chinese website!