Window pageXOffsetandpageYOffsetProperty
Window Object
Definition and Usage
The pageXOffset and pageYOffset properties return the pixels the document has scrolled horizontally and vertically from the upper-left corner of the window.
pageXOffset sets or returns the X position of the current page relative to the upper-left corner of the window's display area. pageYOffset sets or returns the Y position of the current page relative to the upper-left corner of the window's display area.
The pageXOffset and pageYOffset properties are equivalent to the scrollX and scrollY properties.
These properties are read-only.
Syntax
window.pageYOffset
Browser Support
The numbers in the table indicate the first browser version number that supports the property.
| Property | |||||
|---|---|---|---|---|---|
| pageXOffset | Yes | 9.0 | Yes | Yes | Yes |
| pageYOffset | Yes | 9.0 | Yes | Yes | Yes |
All major browsers support the pageXOffset and pageYOffset properties.
Note:IE 8 and earlier IE versions do not support this property, but you can use the document.documentElement.scrollLeft and document.documentElement.scrollTop properties.
Examples
Examples
Scroll the content vertically and horizontally by 100 pixels, and pop up pageXOffset and pageYOffset:
Try it Yourself »
Examples
Compatibility solution (use scrollLeft and scrollTop in IE8 and earlier versions):
Try it Yourself »
Window Object Other Extensions