View Full Version : How would I make the focus jump to the next element (anchor?) in a page? (vBulletin)

06-04-2009, 04:21 PM
vBulletin uses a template system so I can't create a separate element for everything -- we have had several people ask for a "skip to the next post" feature and I'd like to implement that for them

My first thought was to use anchor tags such as:
<a name="$post[postid]">
for each post and then to create a link for "Jump to Next Post" which would advance the user to the next instance of <a name="$post[postid]"> in which the postid obviously would've changed.

With that I didn't know if there was a way that I could have javascript look for the next instance of this, or to pull the postid number and add 1 to it to find the next post on the page. I'm also not sure if it would need to be as complicated as reading where it was at and then adding one and directing person to that anchor point, which is why I thought maybe it could just look for the next instance of <a name="$post[postid]"> and refocus the screen on that.

Sorry that I don't have any sample code as I'm not even sure how to approach this, I searched on here as well as on a few search engines for over an hour and really couldn't find anything that was similar to what I'm looking for even in a general sense. It doesn't have to be an anchor, it can be a hidden input, whatever makes the JS be able to seek it as a point to move the page to. We do have some members that select a different number of posts per page than the default, so I'm guessing that the plus one might not be a great idea if they used a smaller number per page and then clicked the last one, whereas people with more per post wouldn't need to stop at the same point before it no longer let them. If there's a solution for that, that'd be great as well (such as once it hits the last element on the page, it no longer receives instruction, goes to the top of the page, or something).

Thanks for reading and thanks in advance for any help, direction, or code!

06-04-2009, 06:20 PM
This help?

http://www.vbulletin.org/forum/showthread.php?t=91896 :confused:

06-05-2009, 02:39 AM
That might just work, for some reason I didn't pull that up when I searched. There's no demo and I'm not sure if it's 100% what I'm looking for but I'll try to port it over and see. Thanks a lot!

If anybody else has any ideas it would be also welcome.