0

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?

Josh Crozier
  • 202,159
  • 50
  • 343
  • 273
Kay
  • 85
  • 11

1 Answers1

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
  • 687
  • 4
  • 7