Suppose an user wants to select all the content from a webpage, he/she selects and start dragging the pointer to the bottom edge of the window. Now who can we make the webpage scroll down.
If someone starts scrolling the page by selecting some text then it's the responsibility of the window to scroll down. If you want to make some scrolling events then you might have to use window.scrollTo method.
function scrollWin() {
window.scrollTo(200, 0);
}
<!DOCTYPE html>
<html>
<style>
body {
width: 5000px;
}
</style>
<body>
<h1>The Window Object</h1>
<h2>The scrollTo() Method</h2>
<p>Click to scroll the document.</p>
<button onclick="scrollWin()" style="position:fixed">Scroll to 200 horizontally!</button><br><br>
</body>
</html>