0

I'm trying to get javascript to scroll the page to a target position, something like:

scrollbarxpos += (targetscrollbarxpos - scrollbarxpos) / 100.0f;

And basically keep calling that line of code until scrollbarxpos = targetscrollbarxpos.

Any idea how I can go about doing this?

2 Answers 2

2

Have you looked at the scrollTo function? It allows you to scroll to a position on a page with x- or y- coordinates. If you want to animate the scroll, you could use some combination of setInterval and clearInterval to call scrollTo until you've reached your desire y-position.

Sign up to request clarification or add additional context in comments.

Comments

0

You can always use jQuery:

http://jsfiddle.net/jtbowden/vJmcK/

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.