PDA

View Full Version : smooth scroller help



chuco61
08-08-2008, 03:52 PM
OK i have three files for a smooth scroller that i downloaded from this site


what i want to do is make this javascript call start at the bottom then as you click links go up. So opposite of what this code is doing.

Can any on help please?

thanks

i got the files here.

http://www.dezinerfolio.com/2007/08/08/df-javascript-smooth-scroll/

Jesdisciple
08-08-2008, 05:10 PM
EDIT: According to the page you linked, you should try this:
window.onload = function(){
document.getElementById('footer').scrollIntoView();
}

chuco61
08-08-2008, 11:19 PM
i will try it when i get home. Thanks for taking the time to look into this :cool:

chuco61
08-09-2008, 02:40 AM
where exactly would i place this in the code?

mburt
08-09-2008, 02:49 AM
<html>
<head>
<script type="text/javascript">
window.onload = function(){
document.getElementById('footer').scrollIntoView();
}
</script>
</head>
<body>
</body>
</html>

Jesdisciple
08-09-2008, 04:41 AM
That's weird... I can't find where on that site I found that. (I think I actually only saw it here (http://developer.mozilla.org/en/docs/DOM:element.scrollIntoView).) After finally understanding that the decompressed source was in the archive I downloaded, I now think you should try this instead:
window.onload = function(){
var footers = document.getElementsByName('footer');
footers[footers.length - 1].scrollIntoView();
};That uses the correct DOM method for locating the anchor, but still uses the quick scroll because I don't think users want to wait for the page to scroll right after it loads. (To use the smooth scroll, just call the element's onclick method instead.) It also tries to adapt to the unlikely coincidence that two elements in the document are named "footer" by picking the last one.

Of course, you should put that code alongside the Smooth Scrolling script - in a separate script-tag (and JS file) if you prefer.

mburt
08-09-2008, 03:27 PM
Of course, you should put that code alongside the Smooth Scrolling script - in a separate script-tag (and JS file) if you prefer.

Oops, sorry. I assumed the "window" identifier would naturally be in the <head>

Jesdisciple
08-09-2008, 05:42 PM
Your example is correct... Having the script-tag in the head with or without a src attribute is essentially the same. But since he seems uninformed I wanted to be clear that what you posted isn't what his entire page should look like (a silly idea to us, but everyone's a newbie at something).

chuco61
08-11-2008, 03:18 PM
Great i will try this when i get home. Much appreciated.

And, yes i am a newb at javascript