8

I want to automatically scroll the page to 120px as the page loads please help.

I am new to Javascript and jQuery so please use easy javascript or jQuery (And P.S. I'm familier with the "function" thing in javascript).

THANX.

  • What have you tried already? These might help: http://stackoverflow.com/questions/1144805/how-do-i-scroll-to-the-top-of-the-page-with-jquery?rq=1, http://stackoverflow.com/questions/12761971/scroll-to-before-page-load?rq=1 – Adam Marshall Aug 28 '13 at 07:46

4 Answers4

9

Demo Here

Code $("html, body").animate({ scrollTop: 1000 }, 2000);

S. S. Rawat
  • 5,943
  • 4
  • 43
  • 59
6
$("body").animate({ scrollTop: 120 }, "slow");

Working Demo

Make sure that,You write the above line in document.ready() function

Suresh Atta
  • 120,458
  • 37
  • 198
  • 307
5

JavaScript approach

DEMO by sᴜʀᴇsʜ ᴀᴛᴛᴀ

document.body.scrollTop = 1000;
Community
  • 1
  • 1
Tushar Gupta - curioustushar
  • 58,085
  • 24
  • 103
  • 107
1

If you are scrolling to a particular element with id element-id, you can use this:

document.getElementById("element-id").scrollIntoView();
Mohamed Khamis
  • 7,731
  • 10
  • 38
  • 58