Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
370 views
in Technique[技术] by (71.8m points)

javascript - Why were window.scrollY and window.scrollX introduced?

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...