Forum Moderators: open
The pagination is styled in css and I have a current-page style for the link that is the current page.
My question is: How or what javascript can you provide that can automatically highlight the current page that the visitor is on without me having to code the current page link for every page within the pagination. The javascript should use my current-page style that I created for the link as well. Hope you guys understand what I'm talking about.
However, I do feel strongly that having 25 pages of uncategorized links is a bad, bad idea. If you're doing it because you're link-trading and think it'll help your search rankings, I believe you're mistaken. The SE's are smart enough to discount the value of link trades and huge link pages. I *never* do link trades and I rule the SERPs for my preferred keywords.
If you really must have 25 pages of links, then make it useful and turn it into a *directory*, where the links are *categorized*, and have excellent descriptions. The categories can be things like "Blue Widgets", "Red Widgets", or "U.S. Widgets", "French Widgets", etc. Then your links won't be to 1, 2, 3, etc., they'll be to those category names.
Because I feel so strongly that this is the route you should go, I'm afraid I feel I must decline to answer the question of how to style the links with Javascript.
var the_As = document.getElementById('paginationDiv').getElementsByTagName("A");
for(var i=0; i<the_As.length; i++){
if(the_As[i].href == location.pathname){ // you'll need to do more vigorous checking here
the_As[i].className = 'current';
}
}
But, I agree with orion_rus and Fotiman... this is typically something done on the server side, not on the client. While MichaelBluejay makes an excellent point about robbing the majority of the users of features, in this case Javascript brings nothing to the table that can't be accomplished server side and then enjoyed by all users.
Hopefully you are already generating your pagination links server side -- just add in some logic like what's shown above to print a different class name for the current link.
[edited by: Fotiman at 3:50 pm (utc) on Dec. 12, 2006]
On the other OTHER hand, I don't think *anyone* ought to have 25 unorganized links pages. :)
Hope you guys understand what I'm talking about.
I know exactly what you are talking about. There was a presentation at pubcon that went into detail how this is accomplished. As far as method, I agree wholeheartedly with the community here in that server-side technology is the answer, and with a whole bunch of benefits, including code reduction which in turn offers saved bandwidth, saved backup time, ... the list goes on.
There is a very small code sample in the PHP Server Side Scripting Forum that introduces the concept of Hiding hyperlinks for page displayed [webmasterworld.com]