Results 1 to 9 of 9

Thread: smooth scroller help

  1. #1
    Join Date
    Aug 2008
    Posts
    41
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default smooth scroller help

    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/...smooth-scroll/

  2. #2
    Join Date
    Jul 2006
    Posts
    497
    Thanks
    8
    Thanked 70 Times in 70 Posts

    Default

    EDIT: According to the page you linked, you should try this:
    Code:
    window.onload = function(){
        document.getElementById('footer').scrollIntoView();
    }
    Last edited by Jesdisciple; 08-08-2008 at 05:21 PM.
    -- Chris
    informal JavaScript student of Douglas Crockford
    I like wikis - a lot.

  3. #3
    Join Date
    Aug 2008
    Posts
    41
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    i will try it when i get home. Thanks for taking the time to look into this

  4. #4
    Join Date
    Aug 2008
    Posts
    41
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    where exactly would i place this in the code?

  5. #5
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default

    Code:
    <html>
    <head>
    <script type="text/javascript">
    window.onload = function(){
        document.getElementById('footer').scrollIntoView();
    }
    </script>
    </head>
    <body>
    </body>
    </html>
    - Mike

  6. #6
    Join Date
    Jul 2006
    Posts
    497
    Thanks
    8
    Thanked 70 Times in 70 Posts

    Default

    That's weird... I can't find where on that site I found that. (I think I actually only saw it here.) After finally understanding that the decompressed source was in the archive I downloaded, I now think you should try this instead:
    Code:
    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.
    Last edited by Jesdisciple; 08-09-2008 at 05:28 AM.
    -- Chris
    informal JavaScript student of Douglas Crockford
    I like wikis - a lot.

  7. #7
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default

    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>
    - Mike

  8. #8
    Join Date
    Jul 2006
    Posts
    497
    Thanks
    8
    Thanked 70 Times in 70 Posts

    Default

    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).
    -- Chris
    informal JavaScript student of Douglas Crockford
    I like wikis - a lot.

  9. #9
    Join Date
    Aug 2008
    Posts
    41
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Great i will try this when i get home. Much appreciated.

    And, yes i am a newb at javascript

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •