Copyright © tutorialspoint.com
This method scrolls the window so that element appears at the top of the viewport.
This has a similar effect than what would be achieved using HTML anchors (except the browser's history is not modified).
element.scrollTo(); |
<html> <head> <title>Prototype examples</title> <script type="text/javascript" src="/javascript/prototype.js"> </script> <script> function showResult() { $('heading').scrollTo(); } </script> </head> <body"> <h1 id="heading">This is the heading.</h1> <p id="test">Click the button see the result.</p> <p id="test">Click the button see the result.</p> <p id="test">Click the button see the result.</p> <p id="test">Click the button see the result.</p> <p id="test">Click the button see the result.</p> <p id="test">Click the button see the result.</p> <p id="test">Click the button see the result.</p> <p id="test">Click the button see the result.</p> <p id="test">Click the button see the result.</p> <p id="test">Click the button see the result.</p> <p id="test">Click the button see the result.</p> <p id="test">Click the button see the result.</p> <p id="test">Click the button see the result.</p> <p id="test">Click the button see the result.</p> <p id="test">Click the button see the result.</p> <p id="test">Click the button see the result.</p> <p id="test">Click the button see the result.</p> <p id="test">Click the button see the result.</p> <p id="test">Click the button see the result.</p> <p id="test">Click the button see the result.</p> <p id="test">Click the button see the result.</p> <p id="test">Click the button see the result.</p> <p id="test">Click the button see the result.</p> <p id="test">Click the button see the result.</p> <input type="button" value="Click" onclick="showResult();"/> </body> </html> |
To understand it in better way you can Try it yourself.
Copyright © tutorialspoint.com