As far as I know, pageXOffset/pageYOffset
properties were already available since Netscape 4 era.
And it seems scrollX/scrollY
were introduced circa Netscape 6.
Alternative question:
Q2. Is there a browser which implements scrollX/scrollY but doesn't support pageXOffset/pageYOffset?
I will add a third question because no one was able to answer the previous ones:
Q3. scrollX/scrollY was added to the latest editor's draft of the CCSOM and the working draft only got pageXOffset/pageYOffset, why are they keeping both attributes?
scrollX. The read-only scrollX property of the Window interface returns the number of pixels that the document is currently scrolled horizontally. This value is subpixel precise in modern browsers, meaning that it isn't necessarily a whole number.
The read-only Window property pageYOffset is an alias for scrollY ; as such, it returns the number of pixels the document is currently scrolled along the vertical axis (that is, up or down) with a value of 0.0, indicating that the top edge of the Document is currently aligned with the top edge of the window's content ...
According to MDN, the pageXoffset and pageYoffset is not deprecated.
The scrollY property returns the pixels a document has scrolled from the upper left corner of the window. The scrollY property is read-only.
Is there a browser which implements scrollY/X but doesn't support pageY/XOffset
I guess what you want to know is whether you can fully trust pageY/XOffset
and leave scrollY/X
out of the game. The answer is yes. pageY/XOffset
is working in Firefox, Chrome, Opera, and IE 9!
I can't test scrollX/Y
on IE9 currently, but it is not listed on MSDN properties so there is a good chance it answers your question. So there may be browsers implementing pageY/XOffset
but not scrollY/X
.
Why were window.scrollY and window.scrollX introduced?
As scrollY
is only an alias, I'm sure it is only for better readability.
Everything about it. As you can see pageXOffset
isn't supported by Internet Explorer 8 and below. In IE8 (and lower) you should use scrollLeft
/ scrollTop
of document.body
or document.documentElement
depending what works (just like it is implemented in jQuery).
You can check it here: http://jsfiddle.net/8RFAn/1/
And I don't know why window.scrollX/Y
were introduced, for me these properties looks like pageX/YOffset
in terms of effect and browsers in which are implemented.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With