METHOD:  Window::scrollTo


window.scrollTo(xPosition, yPosition)

This method scrolls the contents of a window, the specified co-ordinate becoming the top left corner of the viewable area. Both parameters are integers and they represent the x and y co-ordinates in pixels. This method is only useful where there are areas of the document not viewable within the current viewable area of the window and the visible property of the window's scrollbar must be set to true (enabled).

The following example assigns the toTop() function to the onClick event handler of a button. Note that for this example to have any noticable effect, the button must be placed below the bottom of the default viewable area of the window, i.e. you have to scroll down to be able to see the button.

Code:
<script type="" language="JavaScript">

function toTop() {
        self.scrollTo(0, 0)
}

</script>

<form action="" method="POST" id="myForm">
<input type="Button" name="" value="Top" id="myButton" onClick=toTop()>
</form>


Copyright 1999-2001 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information