Any idea what, if any, difference there is between window.scroll(x, y)
and window.scrollTo(x, y)
[not talking about jQuery]?
Also any ideas as to which browsers support which? Thanks
Any idea what, if any, difference there is between window.scroll(x, y)
and window.scrollTo(x, y)
[not talking about jQuery]?
Also any ideas as to which browsers support which? Thanks
There are no differences: https://developer.mozilla.org/en/DOM/window.scroll
As far as I know, all major browsers support both.
scroll()
'scrolls the window to a particular place in the document' and scrollTo()
'scrolls to a particular set of coordinates in the document' ;) –
Peddler Window.scrollTo()
is effectively the same as the window.scroll(x,y)
method. For scrolling a particular distance, use Window.scrollBy()
.
Also see Window.scrollByLines()
, Window.scrollByPages()
and Element.scrollIntoView()
MDN - https://developer.mozilla.org/en-US/docs/Web/API/Window/scroll
In the absence of deprecation, I prefer window.scroll
instead of window.scrollTo
:
window.scrollTo
by referring to window.scroll
, suggesting that window.scroll
is authoritative.window.scroll
has ~3M search results; window.scrollTo
has ~0.5M.There is scrollTo, scroll, and scrollBy! Apparently there is no standard covering this functionality so all Browsers may not implement it the same.
scrollBy
is unlike the others in that it scrolls relative to the current position. –
Fetterlock © 2022 - 2024 — McMap. All rights reserved.