
- HTML Tutorial
- HTML - Home
- HTML - Overview
- HTML - Basic Tags
- HTML - Elements
- HTML - Attributes
- HTML - Formatting
- HTML - Phrase Tags
- HTML - Meta Tags
- HTML - Comments
- HTML - Images
- HTML - Tables
- HTML - Lists
- HTML - Text Links
- HTML - Image Links
- HTML - Email Links
- HTML - Frames
- HTML - Iframes
- HTML - Blocks
- HTML - Backgrounds
- HTML - Colors
- HTML - Fonts
- HTML - Forms
- HTML - Embed Multimedia
- HTML - Marquees
- HTML - Header
- HTML - Style Sheet
- HTML - Javascript
- HTML - Layouts
- HTML References
- HTML - Tags Reference
- HTML - Attributes Reference
- HTML - Events Reference
- HTML - Fonts Reference
- HTML - ASCII Codes
- ASCII Table Lookup
- HTML - Color Names
- HTML - Entities
- HTML - Fonts Ref
- HTML - Events Ref
- MIME Media Types
- HTML - URL Encoding
- Language ISO Codes
- HTML - Character Encodings
- HTML - Deprecated Tags
What is the role of pageYOffset property?
If you want to get the pixels of the document scrolled to from the upper left corner of the window, then use the pageXoffset and pageYoffset property. Use pageYoffset for vertical pixels.
Example
You can try to run the following code to learn how to work with pageYOffset property in JavaScript.
<!DOCTYPE html> <html> <head> <style> div { background-color: green; height: 1500px; width: 1500px; } </style> </head> <body> <script> function scrollFunc() { window.scrollBy(200, 200); alert("Vertical: " + window.pageYOffset); } </script> <button onclick="scrollFunc()" style="position:fixed;">Scroll</button> <br><br><br> <div> </div> </body> </html>
- Related Articles
- HTML Window pageYOffset Property
- What is the role of pageXOffset property in JavaScript?
- What is the role of scrollY property in JavaScript?
- What is the role of scrollX property in JavaScript?
- What is the role of global RegExp property in JavaScript?
- What is the role of source RegExp property in JavaScript?
- What is the role of lastIndex RegExp property in JavaScript?
- What is the role of Keyboard Event shiftKey Property in JavaScript?
- What is the role of Keyboard Event ctrlKey Property in JavaScript?
- What is the role of Keyboard Event altKey Property in JavaScript?
- What is the role of ignoring Case RegExp property in JavaScript?
- What is the role of ATP?
- What is the role of mitochondria?
- What is the role of Lysosome?
- What is the role of Compiler Construction Tools?

Advertisements