window.scrollTo(x,y)

In this chapter you will learn:

  1. How to scroll a window

Scroll a window

window.scrollTo(x, y) scrolls to the specified position.

<!DOCTYPE HTML> <!--from   j ava 2  s. c o m-->
<html> 
    <body> 
        <p> 
            This is a test. <br/>
            This is a test. <br/>
            This is a test. <br/>
            This is a test. <br/>
            This is a test. <br/>
            This is a test. <br/>
            This is a test. <br/>
            This is a test. <br/>
            This is a test. <br/>
            This is a test. <br/>
            This is a test. <br/>
            This is a test. <br/>
            This is a test. <br/>
            This is a test. <br/>
            This is a test. <br/>
            This is a test. <br/>
            This is a test. <br/>
            This is a test. <br/>
            This is a test. <br/>
            This is a test. <br/>
            This is a test. <br/>
            This is a test. <br/>
            This is a test. <br/>
            This is a test. <br/>
            This is a test. <br/>

        </p> 
        <script> 
            window.scrollTo(0, 400); 
        </script> 
    </body> 
</html>

Click to view the demo

Next chapter...

What you will learn in the next chapter:

  1. How to get window location
Home » Javascript Tutorial » Window
Window Object
alert()
close()
confirm()
find()
Window height and width
location
window.moveBy
window.moveTo
window.open()
window.print()
window.prompt()
resizeTo(x,y) and resizeBy(xDelta,yDelta)
window.scrollTo(x,y)
screenLeft, screenX, screenTop, screenY
setInterval()
setTimeout()