469,931 Members | 2,658 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,931 developers. It's quick & easy.

scroll/Move webpage Location upon Load?

bats fur eels
Hi, I was hoping if anyone knew if it were possible using HTML or other basic scripts that enable you to lets say, scroll the webpage down a few margins upon load of page or script. So that it will automatically scroll down for you in case their is a certain spot of the website that you want them to see first. Or in the case of a profile, etc, you can automatically have it scroll down to a certain section in your profile instead of the user having to scroll down themselves.

But after it moves from point A, to point B vertically. The script should then be over untill page refresh. I hope this makes sense and is possible..

Another instance would be on this site, if you were to add the code, instead of the page loading and u seeing the top menu bar for thescripts.com, w/ PMs | Control panel | Buddy List, etc.. It would move the page to perfectly make the topmost the HOME DISCUSSIONS TUTORIALS MEMBERS FAQ. I hope that helps make sense.

Any help would be extremely appreciated. Thank you all.
Jan 19 '07 #1
4 14759
For some reason I wasn't able to locate a way to edit my message above, so I had to reply, but I wanted to say that I'm looking for either html or another code based script. I can't use something that would have to be uploaded to a server and such. So hopefully a verticle scroll code for html would be perfect. Thanks.
Jan 19 '07 #2
acoder
16,027 Expert Mod 8TB
For some reason I wasn't able to locate a way to edit my message above, so I had to reply, but I wanted to say that I'm looking for either html or another code based script. I can't use something that would have to be uploaded to a server and such. So hopefully a verticle scroll code for html would be perfect. Thanks.
You can't edit messages after 5 minutes, I think.

There are two ways that I know of. The HTML way is to declare the following where you want to scroll to:
[HTML]<a name="somename">[/HTML] then the page could be scrolled to that automatically by accessing e.g.
[HTML]http://www.yourwebsite.com/yourpage.html#somename[/HTML]

The javascript way is to use scrollTo with the co-ordinates from the left and top to where you want to scroll to, e.g.
Expand|Select|Wrap|Line Numbers
  1. window.scrollTo(0,100);
See this for an example.
To achieve this on page load, use on body onload
[HTML]<body onload="window.scrollTo(0,100); ...>[/HTML] or define a function and call that instead.
Jan 19 '07 #3
and also
you can do something like
Jan 22 '07 #4
dangit it messed up my last post:
you can do something liek:

[HTML]<a name="start">This Is Where It Jumps To</a>

[rest of page]

<script>
location.replace=document.location.href+"#start";
</script>[/HTML]
Jan 22 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

10 posts views Thread by Scott | last post: by
10 posts views Thread by berg | last post: by
17 posts views Thread by n. Smith | last post: by
2 posts views Thread by Kevin | last post: by
1 post views Thread by id86 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.