How to automatically scroll the page using javascript?

Asked

Viewed 371 times

0

I am developing a screen where you have a step by step and use slideup and slideDown close and open the related Divs.

How do I automatically track the page scroll when I scroll down?

  • Similar to the use of anchor links?

  • Exactly, it would be something similar. It is a form and according to which each question is answered one hides and descends the next. In that I want to make the page follow also, you understand?

1 answer

0


Try using this Javascript function when doing the last step of the screen.
window.scrollTo(xpos, ypos);
Ex:
function onFinish(){ window.scrollTo(40, 0); }

  • How do I find this correct position of the x and y axes? I used something similar and it worked, but not as wanted due to exactly this. How to position right. Can help me?

  • With jQuery you can take these positions from the div var p = $( "yourDiv" );
var position = p.position();
position.left;
position.top;

Browser other questions tagged

You are not signed in. Login or sign up in order to post.