You can use element.scrollTop
and element.scrollLeft
to get the vertical and horizontal offset, respectively, that has been scrolled. element
can be document.body
if you care about the whole page. You can compare it to element.offsetHeight
and element.offsetWidth
(again, element
may be the body) if you need percentages.
Related Posts:
- Wait 5 seconds before executing next line
- Is it possible to sandbox JavaScript running in the browser?
- window.onload vs document.onload
- Scroll to an element with jQuery
- jQuery.click() vs onClick
- What is event bubbling and capturing?
- Scroll to an element with jQuery
- What is DOM Event delegation?
- Onclick javascript to make browser go back to previous page?
- How to get the browser to navigate to URL in JavaScript
- Adding an onclick event to a div element
- iFrame onload JavaScript event
- scrollIntoView Scrolls just too far
- How do you Hover in ReactJS? – onMouseLeave not registered during fast hover over
- Scroll Automatically to the Bottom of the Page
- Why doesn’t JavaScript support multithreading?
- How to remove all listeners in an element?
- Is it possible to append to innerHTML without destroying descendants’ event listeners?
- Is it possible to simulate key press events programmatically?
- How to disable scrolling temporarily?
- How to scroll an HTML page to a given anchor
- window.onload vs $(document).ready()
- jQuery scrollTop() method not working
- How to scroll to top of page with JavaScript/jQuery?
- How can I stop the browser back button using JavaScript?
- Why onbeforeunload event is not firing
- How to make HTML element resizable using pure Javascript?
- window.location.href doesn’t redirect
- What does “javascript:void(0)” mean?
- For-each over an array in JavaScript
- How can I remove a specific item from an array?
- require is not defined? Node.js
- Loop inside React JSX
- How to make JavaScript execute after page load?
- Encode URL in JavaScript?
- JavaScript null check
- JavaScript “Uncaught TypeError: object is not a function” associativity question
- Module not found can’t resolve
- How can I get file extensions with JavaScript?
- How to detect Safari, Chrome, IE, Firefox and Opera browser?
- What does on() in JavaScript do?
- AngularJS : Factory and Service?
- What’s the difference between console.dir and console.log?
- Uncaught TypeError: Cannot read property ‘msie’ of undefined
- How to hide a div with jQuery?v
- How do I pass variables and data from PHP to JavaScript?
- How do I set/unset a cookie with jQuery?
- Calling onclick on a radiobutton list using javascript
- How to properly export an ES6 class in Node 4?
- Uncaught Typeerror: cannot read property ‘innerHTML’ of null
- Sorting HTML table with JavaScript
- Counting the occurrences / frequency of array elements
- how to download file in react js
- TypeError: $(…).DataTable is not a function
- Trying to use fetch and pass in mode: no-cors
- Moment.js transform to date object
- jQuery explode string like PHP
- Call Javascript function from URL/address bar
- Anagrams finder in javascript
- Validate date in dd/mm/yyyy format using JQuery Validate
- How to subtract days from a plain Date?
- Stopping a JavaScript function when a certain condition is met
- Showing an image from an array of images – Javascript
- How to filter JSON Data in JavaScript or jQuery?
- What’s the best way to reload / refresh an iframe?
- How do I check if a cookie exists?
- Get querystring from URL using jQuery [duplicate]
- Check if string contains only digits
- JS: iterating over result of getElementsByClassName using Array.forEach
- jQuery checkbox change and click event
- Error: listen EACCES 0.0.0.0:80 OSx Node.js
- jQuery selectors on custom data attributes using HTML5
- How to check if a value is not null and not empty string in JS
- How do I refresh a DIV content?
- TypeError: abc.getAttribute is not a function
- jquery to validate phone number
- Closing Bootstrap modal onclick
- Reading local text file into a JavaScript array
- “NS_ERROR_DOM_BAD_URI: Access to restricted URI denied”
- How can I unset a JavaScript variable?
- D3.js: what is ‘g’ in .append(“g”) D3.js code?
- Reset Undo on the tinymce editor
- Combine enqueue js without affecting dependencies
- WP Customizer set a value via javascript (to create presets)
- JavaScript in page doesn’t open new window [closed]
- wp_enqueue_script adds only the first script
- Add javascript to a woocommerce page template
- Dynamically insert values in a WordPress SelectControl Options field
- Vimeo froogaloop
- can a buttongroup have a label?
- InnerBlocks restricting does not work on nested blocks
- How to open the add media dialogue it in a certain state / tab?
- Putting custom html/js page into Elementor as it’s own block
- Drag-to-Scroll Landingpage
- Easiest way to find JS conflicts
- Nothing in dashboard that uses javascript works
- XMLHttpRequest of admin data to public
- How to execute WP shortcode in a javascript string “”
- PHP or JS for header image rotator?
- How can I look at/edit what’s being sent to post.php when I hit the publish/update button?