-4

I know this question has been asked before but I did not find the solution on those previously asked questions.

Can someone please help me figure out how to scroll my page to a certain spot on when I refresh the page or when I first come in to my page?

user2976340
  • 1
  • 1
  • 1
  • What do you mean by "spot". A certain element? – Johan Nov 10 '13 at 14:52
  • possible duplicate of [jQuery: how to scroll to certain anchor/div on page load?](http://stackoverflow.com/questions/9757625/jquery-how-to-scroll-to-certain-anchor-div-on-page-load) – kero Nov 10 '13 at 14:53
  • The questions you've seen asked before **do** have answers. If you want to say those answers didn't work for you, you must show what you're working with, what you tried, and describe what you expected vs. what you saw. There's no point in simply saying "I want to do X, I know this has been answered, but it didn't work for me" with no detail whatsoever. It's a waste of your time and ours. – T.J. Crowder Nov 10 '13 at 14:59

3 Answers3

1

Well, use on of the solutions below depending on what you need. If you want a "smooth scroll" ypu can search on SO for it. There are a lot of threads covering both this and that.

$(window).scrollTop(200); //to scroll 200px

var targetOffset = $('#yourelement').offset();
$(window).scrollTop(targetOffset.top); //scroll to a certain element

jQuery API on scrollTop()

Smooth scrolling on jsfiddle

Johan
  • 35,120
  • 54
  • 178
  • 293
0

Create an anchor at the point you want to scroll to. On page load you can use jQuery to scroll to that anchor. More here: Jump to anchor tag without showing hashtag in URL

Community
  • 1
  • 1
TheFrozenOne
  • 1,695
  • 9
  • 19
0
$(document).scrollTop( $("#middle").offset().top );  

If you have an element in the middle of the page with ID of #middle, the above code will do the trick. So adjust as needed to scroll to the part of the page you need.

Charlie74
  • 2,883
  • 15
  • 23