I've a page called index.php that contains a div list like this:
<div id="links">
<ul>
<li><a href="example1.php">example1</a></li>
<li><a href="example2.php">example2</a></li>
<li><a href="example3.php">example3</a></li>
......
<li><a href="exampleN.php">exampleN</a></li>
</ul>
</div>
that is the list of page of my site, showed in the index.php page. I want to add a "prev | home | next" menu to each page in the site (example1, example2, example3,...,exampleN), where "prev" gets me to the previous example and next to the next example, i.e. if I'm watching example number 3 (page example3.php), prev takes me to example number 2 (page example2.php) etcetera.
I'd like to use a script that is not based on a fixed array (defined by the user), because I do not want to update this array each time a new page is added to the index.php list.
I thought of a function like this: suppose we're in example2.php
function blahblah(){
1) get the link list using DOM from index.php (using an array)
2) search for "example2.php" in the href value of each element in the list, to get the index of the array: in this case, "example2.php" is the 2nd link of index.php, so the array index will be 1 (i.e. alert(linkList[1].href) will print "example2.php")
3) once we know the index, previous page index will be "index-1" and next page will be "index+1"
}
About getting the list (1st point in my pseudocode), I don't know how to acces other pages (on the same domain) using DOM elements.. does someting like document("page").getElementById('links') exist without the need of an iframe?
I'm on the right track? Or totally wrong? Any help, idea or advice is appreciated. Thanks, best regards