Windows 10 scrolling by itself

broken image
broken image
broken image

The bottom edge of the element will be aligned with the window bottom. If top=false, then the page scrolls to make elem appear at the bottom.The upper edge of the element will be aligned with the window top. If top=true (that’s the default), then the page will be scrolled to make elem appear on the top of the window.The call to elem.scrollIntoView(top) scrolls the page to make elem visible. scrollIntoViewįor completeness, let’s cover one more method: elem.scrollIntoView(top). These methods work for all browsers the same way. To scroll to the very beginning, we can use scrollTo(0,0). The method scrollTo(pageX,pageY) scrolls the page to absolute coordinates, so that the top-left corner of the visible part has coordinates (pageX, pageY) relative to the document’s top-left corner. For instance, scrollBy(0,10) scrolls the page 10px down. The method scrollBy(x,y) scrolls the page relative to its current position. We can do the same for the page using /scrollLeft (except Safari, where /Left should be used instead).Īlternatively, there’s a simpler, universal solution: special methods window.scrollBy(x,y) and window.scrollTo(pageX,pageY). Regular elements can be scrolled by changing scrollTop/scrollLeft. To scroll the page with JavaScript, its DOM must be fully built.įor instance, if we try to scroll the page with a script in, it won’t work.