By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,645 Members | 1,226 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,645 IT Pros & Developers. It's quick & easy.

scroll/Move webpage Location upon Load?

bats fur eels
P: 2
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
Share this Question
Share on Google+
4 Replies


bats fur eels
P: 2
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
Expert Mod 15k+
P: 16,027
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

P: 2
and also
you can do something like
Jan 22 '07 #4

P: 2
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.