How to use Window Object ScrollTo in JavaScript

In this article I am going to explain about window object ScrollTo() Method in JavaScript.
  • 2073

JavaScript Window Object ScrollTo() Method

JavaScript ScrollTo() method also use for scroll the content on the page but main purpose of this is to scroll the specifies number of coordinate on the the page.

Syntax

 

scrollTo(X,Y)

Example

<html>

<head>

    <script type="text/javascript">

        function myfun() {

            window.scrollTo(100, 200);

        }

    </script>

</head>

<body>

    <button onclick="myfun()">

        click me</button>

    <p>

        Window object Scroll() method</p>

    <br />

    <br />

    <br />

    <p>

        Window object Scroll() method</p>

    <br />

    <br />

    <br />

    <br />

    <p>

        Window object Scroll() method</p>

    <br />

    <br />

    <br />

    <br />

    <p>

        Window object Scroll() method</p>

    <br />

    <br />

    <br />

    <br />

    <p>

        Window object Scroll() method</p>

    <br />

    <br />

    <br />

    <br />

    <p>

        Window object Scroll() method</p>

    <br />

    <br />

    <br />

    <p>

        Window object Scroll() method</p>

    <br />

    <br />

    <br />

    <br />

</body>

</html>

 

Output


scr1.gif


After button click


scr2.gif

 

You may also want to read these related articles: here
 
Ask Your Question 
 
Got a programming related question? You may want to post your question here
 

Categories

More Articles

© 2020 DotNetHeaven. All rights reserved.