views:

953

answers:

3

I'm looking for away to scroll the window to a specified position from the window's current position, NOT from the top of the window.

From the bit of playing around I've done I can't find a way to do this. I've also tried messing around with the scrollTo plugin and it exhibits the same behavior. They all reset the window's position to the top left, then scroll to the target location. Is it even possible?

Thanks.

EDIT I made an embarrassingly dumb mistake. One little missed return false; :s

+1  A: 

You can find your current position using pageXOffset and pageYOffset.

Then you can use the scrollTo plugin to scroll to another position relative to your current one.


EDIT: You should use $(document).scrollTop(), like @David says. jQuery likey :)

Here Be Wolves
+1  A: 

You can get the distance scrolled using $(document).scrollTop(). Just add that number to your desired position.

David
A: 

You could just skip up/down the page using good ol' anchor tags:

<A href="#furtherdown">go down</a>
...
...
<a name="furtherdown />

This will scroll the page so that the <a name> tag is at the top of the viewport.

AUSteve