Ok, so I have this li list with about 24 list elements. I want the webpage to be able to automatically scroll to the point where I assigned a specific li active/current on onload. How can I do this using JavaScript?
Asked
Active
Viewed 60 times
0
-
Similar [answer][1] using jquery scrolltop hope it helps. [1]: http://stackoverflow.com/questions/6677035/jquery-scroll-to-element – tmcc Jun 25 '13 at 21:27
-
Was more hoping for Javascript – Kay Jun 26 '13 at 15:36
1 Answers
0
Javascript has a Window Object Method, scrollTo(), for scrolling (read about it here: http://w3schools.com/jsref/met_win_scrollto.asp). However, this can be inconvenient if you don't know the exact coordinates you want to jump to. One alternative worth trying is using a named link like <a id="active"></a>
and telling JS to load the page with #active at the end of the URL. That's always an easy way to force scrolling.

Ian Drake
- 737
- 4
- 7