This article focuses on ScrollBar control. Three methods are provided to control ScrollBar with Javascript ), I hope you will have a deep understanding of how to control the scroll bar through this article.
Use Javascript to control ScrollBar (scroll bar)
The following items are automatically rolled to the bottom by default. to scroll to the top, you only need to change document. body. scrollHeight to 0.
Method 1: Use scroll
- <body onload="scroll(0,document.body.scrollHeight) ">
- <script>
- document.write(new Array(100).join("<br>"))
- </script>
Method 2: Use the scrollBy Method
- <body onload="scrollBy(0,document.body.scrollHeight) ">
- <script>
- document.write(new Array(100).join("<br>"))
- </script>
-
Method 3: Use the scrollTo Method
- <body onload="scrollTo(0,document.body.scrollHeight)">
- <script>
- document.write(new Array(100).join("<br>"))
- </script>
-
If you want to control the ScrollBar of the Framework in the framework, add parent, for example, parent. scrollTo );