Back to Back and Forward Buttons New

//All you have to do is to add files to this list below:

//First get your list of files in the order you want them:

database=new Array("index.html","alerts.htm","alertsText.htm","alertsImages.htm","jumpfunction.htm","alertConfirm.htm","alertConfirm2Locs.htm","alertOnLoad.htm","alertHelloEx.htm","HoverButtons.htm","alertPrompts.htm","alertPromptEx.htm","documentWrite.htm","documentWrite2.htm","alertPromptEx2.htm","WindowNew.htm","WindowNew2.htm","WindowNewHyperlinks.htm","menu1.htm","menuSelectOnChange.htm","ArrayText.htm","ArrayTextImage.htm","jsFrames.htm","frameHyperlinks.htm","history.htm","BackForwardSimple.htm","BackForward.htm","BackForwardNew.htm");

//The above is all you need to change!

//We want to automatically discover the number of files


//Next find out which page, this one is//

//We use the location.href property and extract the filename

//from this string using lastIndexOf:






//Now we find the current page nunmber (in the list)

//Remember that Arrays start at 0 and end at number of

//elements less one. So the last element is:


//Now we look through to list to find our file, and

//therefore, its number in the list:

for (var i = 0; i <= n; i++)


if (database[i]==ThisFilename)





//determine the numbers of the previous and the next pages//

function goBack(){


if (ThisPageNumber-1<0)

//We don't want to go into negative numbers or numbers

//bigger than the number of files! So if the file number less

//one is less than zero, there is nowhere left to go!


alert("You are at the beginning of the series")


//Otherwise we just take one of the current file number

//and get the number for the previous file:



function goForward(){


if (ThisPageNumber+1>n){

alert("You are at the end of the series")

//If the user is clicking on the last file, he or she

//cannot go forward. Otherwise, the next file is the current

//file number plus one:





//and so that's our code. All we have to do is to change files

//in the Array database! Nice and lazy!