The SitePoint Forums have moved.

You can now find them here.
This forum is now closed to new posts, but you can browse existing content.
You can find out more information about the move and how to open a new account (if necessary) here.
If you get stuck you can get support by emailing forums@sitepoint.com

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

How to automatically detect total pages

Sometimes when I'm reading a review article on a certain product with too many pages on some websites, I want to go directly from the first page to the last and get to the conclusion.

I'm trying to build a personal tool for firefox that retrieves the dependent pages and returns the conclusion text from the last page. I've already wrote the code to get the innerHTML based on a class getElementsByStyleClass(classname) to get the conclusion text but I want to be able to crawl through all the pages to the last one and retrieve the conclusion text without leaving the first page.

If I understand you correctly, you want to crawl the pagination navigation links for a multi-page article? The solution would rely on the pagination links having some distinguishing characteristic such as a class or id attribute that would allow your script to identify them as such. You would need to use AJAX to load the last page. Preferably, the pages would be valid XHTML so that you could load the page into a DOMDocument instance and use DOM methods to retrieve the desired fragment. (It sounds like you've already implemented the last part, retrieving the desired fragment.)

If the links have a class attribute of "page", it's pretty straightforward - assuming no other links on the page besides the pagination links have that class. Just get all the page links and use the last one. This would be very easy indeed if getElementsByClassName were implemented in all browsers, but as far I know it isn't yet. So we need some extra coding to get the results we want.