你知道 window.scroll(x, y)和 window.scrollTo(x, y)之间有什么区别吗?
window.scroll(x, y)
window.scrollTo(x, y)
还有关于哪些浏览器支持哪些浏览器的想法吗? 谢谢
There are no differences: https://developer.mozilla.org/en/DOM/window.scroll
As far as I know, all major browsers support both.
There is scrollTo, scroll, and scrollBy! Apparently there is no standard covering this functionality so all Browsers may not implement it the same.
Window.scrollTo() is effectively the same as the window.scroll(x,y) method. For scrolling a particular distance, use Window.scrollBy().
Window.scrollTo()
window.scroll(x,y)
Window.scrollBy()
Also see Window.scrollByLines(), Window.scrollByPages() and Element.scrollIntoView()
Window.scrollByLines()
Window.scrollByPages()
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.scroll
window.scrollTo