METHOD: javascript::scroll(xPosition, yPosition)
This Javascript method scrolls the contents of a window, to specified co-ordinate from 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 .
This Javascript method scrolls the contents of a window, to specified co-ordinate from 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 .
<a href="javascript:scroll(0,0)">
Scroll Top
</a>
METHOD: Window::scrollTo
We can also use METHOD:
window.scrollTo(xPosition, yPosition) for this as follows
Code:
<script type=""
language="JavaScript">
function scrollTop()
{
self.scrollTo(0, 0)
}
</script>
<form action="" method="POST" id="frm1">
<input type="Button"
name=""
value="Top"
id="btnscroll"
onClick=scrollTop()>
</form>
The first number is the x position, the second is the y position. (Positions are in pixels.) So, you can also change these numbers to scroll to a specific point on a page, too.