PDA

View Full Version : need a script to scroll down "x" pixels on page enter


ArtisticVisions
09-27-2002, 04:17 AM
I've seen scripts that automatically scroll the page down, but what I'm looking for is a script that will scroll the page down by a certain number of pixels on page enter and stop there. Any help with this would be much appreciated.

Thanks

glenngv
09-27-2002, 04:33 AM
window.scrollTo(xPosition, yPosition);

call it onload

ArtisticVisions
09-27-2002, 05:06 AM
Thanks for the quick reply Glenn, but as a non-programmer I don't know what to do with your answer. :confused: :rolleyes:

I need an example of the script or code and where to place it. For example, if I want the page to scroll down say, 70 pixels when the page opens... how do I accomplish this? It doesn't matter to me if it actually scrolls down or if the page opens already scrolled down, unless one script is significantly smaller.

Thanks again.

glenngv
09-27-2002, 06:25 AM
<html>
<body onload="window.scrollTo(0,70)">
<pre>
blah
blah
blah
blah
blah
blah
blah
blah
blah
blah
blah
</pre>
</body>
</html>

ArtisticVisions
09-27-2002, 06:42 AM
Thanks again Glenn. :thumbsup: Much simpler than I expected! :cool: I'll try it! Never saw the <pre> </pre> tags before though. Are they necessary for the onload attribute to work? What do they do? No hurry on this one. I'll check it out and see how it works. Thanks a lot! :D

glenngv
09-27-2002, 06:52 AM
i just put a dummy content in several lines so that you can see the effect of scrolling down (of course it will still depend on the height of the window). Instead of putting <br> tag at the end of each line, I put <pre> tag.

The <pre> tag is used to display pre-formatted text. The output will mimic exactly how the text is rendered inside the pre element including white space, tabs, and line breaks.

ArtisticVisions
09-27-2002, 07:10 AM
OK, I have seen the <pre> tags before, I just never used them and I thought it was part of the scrolling code... wasn't thinking. :rolleyes: I must seem like a real dummy considering how simple this is and I thought it would be a long javascript or dhtml. We all gotta start somewhere right? Your help is much appreciated! Now I'll try it.