Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: Virtual Pagination: Back to Top

  1. #1
    Join Date
    Oct 2006
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Virtual Pagination: Back to Top

    1) Script Title: Virtual Pagination Script

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

    3) Describe problem:
    When I click on the page number of a long page, it will not send me back to the top of the page, but instead keeps me wherever the "flatview" was in the last page. Is there any way to fix this?

    Thank you in advance!
    Last edited by ddadmin; 03-06-2007 at 02:48 AM.

  2. #2
    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 so we can check it out.

  3. #3
    Join Date
    Oct 2006
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I realize that I sound like an ungrateful, and stupid, jerk when I ask this, but is there any way to get a possible answer without showing the site.

    The reason is that I have a lot of people that look at this site, and we haven't debutted the new design to them yet. I realize it sounds stupid, but there are a lot of people that have a lot of emotional investment in this.

    If that isn't possible, would it be possible to PM it to someone?

    Thanks again!

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

    Default

    Sure, you can pm me the URL if you like. The reason I ask for a URL is that I'm not clear on the issue you're describing. I tried to create a sample test whereby one of the paginated content is very long, though flipping around pages didn't produce the effect you described.

  5. #5
    Join Date
    Oct 2006
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Message sent!

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

    Default

    Ok, I took a look at your page. What you can do is explicitly tell the browser to scroll up whenever a pagination link is clicked on. Inside the .js file, find the code:
    Code:
    if (i>=showstartindex && i<=showendindex)
    this.pieces[i].style.display="block"
    else
    this.pieces[i].style.display="none"
    And change that to:

    Code:
    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"
    Basically the code in red causes the browser to scroll to the top of the content being displayed. If you wish to scroll all the way to the top of the page instead, just change the code in red to:

    Code:
    window.scrollTo(0,0)
    instead.

  7. #7
    Join Date
    Oct 2006
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    That works, but it doesn't hide the previous content from the other pages. If you click all of the links, it ends up with all of the content showing.

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

    Default

    Please check your .js file again- you've implemented the above incorrectly. What you have:
    Code:
    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"
    }
    What it should be:

    Code:
    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"

  9. #9
    Join Date
    Oct 2006
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    When I did it with the "}" none of the content was displayed. I added the "}" to demonstrate what I mean.

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

    Default

    Did you remember the opening { as well:

    Code:
    if (i>=showstartindex && i<=showendindex){

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
  •