views:

152

answers:

6

When the page loads, I want to use Javascript/Jquery to automatically take the user to the 500px downwards. But it has to seem natural.

How can that be done?

+10  A: 

You can use the jquery scrollto plugin. It's very easy.

http://plugins.jquery.com/project/ScrollTo

Jourkey
+1: had that in mind as well when I read the question subject in the list.
BalusC
Is there a lighter version? Just using javascript?
TIMEX
Who would say, there's a jQuery plugin for that...
Martinho Fernandes
+1  A: 

Is there a lighter version? Just using javascript?

You could consider calling window.location.hash during onload. Have an element with an ID at about 500px down and just do

window.onload = function() {
    window.location.hash = '#foo';
}

Oh, the # is mandatory for IE compatibility ;)

BalusC
A: 
$().scrollTop(500);
David
A: 

use the jquery one Jourkey suggested. Cross platform easy to use etc. There is pure JavaScript one you can try, though YMMV on browsers other than IE

"scrollTo Method

Scrolls the window to the specified x- and y-offset. "

http://msdn.microsoft.com/en-us/library/ms536731%28VS.85%29.aspx

Byron Whitlock
+4  A: 

Just Javascript: window.scrollBy(0,500);

luvieere
+1 nice to see a native solution.
David
If you want a lighter version, this is the way to go. You could add a loop so it looks like ScrollTo, the jQuery plugin
Daniel S
I recall a browser incompatibility with this function. Not sure, but I'd check that first.
BalusC
I think IE needs scrollTo() but I'm not sure.
David
yes, window.scrollTo(0,500); seems to be the most compatible way, I would recommend using that instead.
David
A: 

What about navigating to some predefined link inside the page. Foe example see URL pointing to the location inside the page http://en.wikipedia.org/wiki/Uniform%5FResource%5FLocator#cite%5Fnote-0

RocketSurgeon