Get the App
SLTechnology News&Howtos  ›  Development  › 

How to get the location where the web page was scrolled by JavaScript

Shulou Source: shulou.com Published: 2022-06-01 02:56:33 09月22日 Update

This article mainly introduces JavaScript how to get the location where the web page was scrolled, which has a certain reference value. Interested friends can refer to it. I hope you will gain a lot after reading this article. Let's take a look at it.

Get the location where the page was scrolled away function getScrollXY () {

Return document.body.scrollTop

? {

X: document.body.scrollLeft

Y: document.body.scrollTop

}

: {

X: document.documentElement.scrollLeft

Y: document.documentElement.scrollTop

}

} the characteristic of JavaScript 1.JavaScript is mainly used to add interactive behavior to HTML pages. 2.JavaScript can be embedded directly into HTML pages, but writing as a separate js file facilitates the separation of structure and behavior. 3.JavaScript has cross-platform features and can run on multiple platforms with the support of most browsers.

Thank you for reading this article carefully. I hope the article "how to get the location where the web page has been scrolled" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Tags: Articles location web pages behaviors pages support value interests at the same time multiple platforms files more benefits friends browsers features features knowledge structure Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB macOS Redmi Shulou Technology Microsoft