PDA

View Full Version : Virtual Pagination: Back to Top



Jobyn
03-06-2007, 02:14 AM
1) Script Title: Virtual Pagination Script

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex17/virtualpagination.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!

ddadmin
03-06-2007, 02:58 AM
Please post a link to the page on your site that contains the problematic script so we can check it out.

Jobyn
03-06-2007, 03:48 AM
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!

ddadmin
03-06-2007, 09:01 AM
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.

Jobyn
03-06-2007, 12:30 PM
Message sent!

ddadmin
03-07-2007, 01:40 PM
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:


if (i>=showstartindex && i<=showendindex)
this.pieces[i].style.display="block"
else
this.pieces[i].style.display="none"

And change that to:


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:


window.scrollTo(0,0)

instead.

Jobyn
03-07-2007, 02:01 PM
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.

ddadmin
03-07-2007, 11:27 PM
Please check your .js file again- you've implemented the above incorrectly. What you have:


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:


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"

Jobyn
03-08-2007, 12:07 AM
When I did it with the "}" none of the content was displayed. I added the "}" to demonstrate what I mean.

ddadmin
03-08-2007, 12:17 AM
Did you remember the opening { as well:


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

Jobyn
03-08-2007, 12:23 AM
Of course I forgot that. I wouldn't want to seem sensible or knowledgeable.

Wow...sorry for the stupidity at the end.

I can't thank you enough for all the help you have given. I will make sure to mention the DD site and give a big thanks when my site finally debuts.

Again, I am in your debt.

ddadmin
03-08-2007, 12:46 AM
You're welcome :) You can always just blame it on your eye sight hehe.

Jobyn
03-19-2007, 06:12 PM
Just wanted to stop in and mention to everyone that my website has been finished.

www.thepanicattacks.com

On it, you will see a couple of scripts care of DD. Virtual Pagination and Lightbox in particular. Hope you like it!

Also, thank you for your help ddadmin.