Results 1 to 9 of 9

Thread: Virtual Pagination script v2.1: scroll back to top

  1. #1
    Join Date
    Jan 2011
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Virtual Pagination script v2.1: scroll back to top

    1) Script Title: Virtual Pagination script v2.1

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...pagination.htm

    3) Describe problem: The script works like a charm, however, when i click the next or page number, the page doesn't scroll back to the top of the page. It stays exactly where it is. It's a bit annoying, because as a visitor you're scrolling trough the list, click the next page at the bottom and then you're at the bottom of the next page, not at the top as usual.

  2. #2
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    There are a couple of threads on this already, for example: http://www.dynamicdrive.com/forums/s...ad.php?t=18210
    DD Admin

  3. #3
    Join Date
    Jan 2011
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I am sorry, thank you for the reply.

    I replaced the lines you mentioned to the code below, but now it scrolls even more to the bottom. I'd like it to scroll to the top.

    for (var i=0; i<totalitems; i++)
    {
    if (i>=showstartindex && i<=showendindex)
    {
    this.pieces[i].style.display="block"
    if (this.pieces[i].scrollIntoView)
    this.pieces[i].scrollIntoView()
    }
    else
    {
    this.pieces[i].style.display="none"
    }
    }


    I am also getting an error-message:

    Webpage error details
    Message: 'document.getElementById(...)' is null or not an object
    Line: 85
    Char: 3
    Code: 0
    URI: virtualpaginate.js
    Last edited by fng; 02-16-2011 at 01:47 PM.

  4. #4
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    Hmm you might have mis-copied something. Try the below attached .js file instead. To recap, it should jump the user back to the top of the virtual pagination content each time the navigation link is clicked on, ensuring even long content are seen from the very top downwards each time.
    DD Admin

  5. #5
    Join Date
    Jan 2011
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I appreciate all your help.

    Its not working. It stays on the bottom all the time. Did i perhaps erase something in the HTML, like a div name or something? Or has it perhaps something to do with the fact that the pagebrowserbuttons are on the bottom of the page (and not at the top)?

    I am just guessing, I am worthless in JS.

    Again thanks for all your help!

  6. #6
    Join Date
    Jan 2011
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Sorry for the bump, but does anyone has anymore suggestions?

  7. #7
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    Please post a link to the page on your site that contains the problematic script with the modified .js file in place so we can check it out.
    DD Admin

  8. #8
    Join Date
    Jan 2011
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    One of the problems is solved!

    Instead of scrollintoview i had to use window.scrollTo(0,0). You mentioned that in your post and it seems to work like a charm.

    The other problem is a JS-error that only seems to occur in Iexplorer:

    Webpage error details
    Message: 'document.getElementById(...)' is null or not an object
    Line: 85
    Char: 3
    Code: 0
    URI: virtualpaginate.js

    I know you asked me for a link, but i don't have the site online (yet). I have it running on an intranet and all content is loaded dynamically from a database. If you really need it to solve the issue, i'll ofcoarse look for a host and place it online.

  9. #9
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    Hmm without an online example of the problem that error you posted above is simply too vague. Can you simply attach the modified .js file here?
    DD Admin

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
  •