Window.scrollTo() (Method)

Scroll the document in the window to a specific location.

Availability:

JavaScript - 1.2
JScript - 3.0
Internet Explorer - 4.0
Netscape - 4.0
Property/method value type:undefined
JavaScript syntax:-myWindow.scrollTo(aPositionX, aPositionY)
-scrollTo(aPositionX, aPositionY)
Argument list:aPositionXA location in pixels
aPositionYA location in pixels

This method will scroll the window to an absolute position specified by the two values. You can scroll in either the horizontal or vertical axis or even both at once.

Although the method is supported by MSIE and Netscape Navigator, they scroll in opposite directions vertically.

You can use this scrolling facility to bring a specific anchor into view. You would do this by enquiring of the anchor what its X and Y coordinates are and then using that as a scroll destination.

You should use this method in preference to the window.scroll() method which is now deprecated.

Warnings:

See also:Anchor object, Frame object, Window object, Window.scroll(), Window.scrollBy()

insert figure 0078