Hey,
Has anyone every usd javascript to do a "dynamic" pagination script to navigate through html pages?
I whant to be able to dynamicall set a next and pre button to be able to navigate through in order a list of html pages in sequence.
My development thoery would be to create html pages with filenames 1.htm,2.htm and so on. These pages would contain the navigation that simply goes to the prev or next page in sequence.
Im thinking i need to make use of the document.location.pathname but not sure how it all fits together. So if any buddy has any advice or suggestion to give me i would appreciate it. Its what this post is all about
Kendall
Javascript PAgination
Moderator: General Moderators
- artexercise
- Forum Commoner
- Posts: 33
- Joined: Thu Nov 20, 2003 9:38 am
- Location: Raleigh, NC
I've not used it for such but I would set up my Previous and Next links with tags that point to a javascript function that:
1. Gets the current URL and parses it down to the HTML name, eg. bobDole.html.
2. Hack off the html part and send the page name to the proper function. eg. moveForward('bobDole') or moveBackward('bobDole').
3. assuming that 'bobDole.html' is in the same directory as everything else then call 'window.location(targetPage)' and off it goes.
Now, why did I not use 1.html, 2.html, 3.html, etc.? Because I may want to insert a step inbetween sometime in the future and it'll mess up my lovely numbering scheme. How do you get back this point then? Set up an array such as :
theOrder = new Array('harryTruman', 'bobDole', 'jinxTheCat');
And for each page when it loads it can check the array to see if it is first or last or somewhere in the middle. If it's first then block out the Previous hyperlink, if last then the Next hyperlink. And regardless of where a page is, it checks the array to find it's proper place and then either looks +1 or -1 to get the correct html page to go to.
And if you want to insert 'daffyDuck' before 'bobDole' then it's a snap to just drop that item in the array and make the webpage without any coding conundrum.
JOE--
1. Gets the current URL and parses it down to the HTML name, eg. bobDole.html.
2. Hack off the html part and send the page name to the proper function. eg. moveForward('bobDole') or moveBackward('bobDole').
3. assuming that 'bobDole.html' is in the same directory as everything else then call 'window.location(targetPage)' and off it goes.
Now, why did I not use 1.html, 2.html, 3.html, etc.? Because I may want to insert a step inbetween sometime in the future and it'll mess up my lovely numbering scheme. How do you get back this point then? Set up an array such as :
theOrder = new Array('harryTruman', 'bobDole', 'jinxTheCat');
And for each page when it loads it can check the array to see if it is first or last or somewhere in the middle. If it's first then block out the Previous hyperlink, if last then the Next hyperlink. And regardless of where a page is, it checks the array to find it's proper place and then either looks +1 or -1 to get the correct html page to go to.
And if you want to insert 'daffyDuck' before 'bobDole' then it's a snap to just drop that item in the array and make the webpage without any coding conundrum.
JOE--