Click to See Complete Forum and Search --> : back & forward buttons WITHOUT using history
skytrekr
12-19-2002, 04:28 PM
I've got a directory with 13 pages in it. It's a presentation.
The pages appear in the main frame of a frame set with the navigation in the bottom frame. I want to create a linear navigation where I can just click Next--Next--Next etc to browse the entire directory.
The files are named: slide01.asp, slide02.asp, slide03.asp, etc. etc.
Anybody have the answer for this one?:confused:
skytrekr
12-19-2002, 04:46 PM
Any suggested would be greatly appreciated.
khalidali63
12-19-2002, 05:01 PM
use the following JavaScript method calls for this functionality
function goForward(){
location.href = "forward.html"
}
function goBack(){
location.href = "back.html"
}
create 2 buttons in each page
forward and back and in there oncllick events call the apropriate methods
Khalid
skytrekr
12-20-2002, 11:36 AM
OK, I think you've pointed me in the right direction. But I'm still having problems.
I set up a test site for a script which goes like this:
I have a directory with 5 files in it. They are BackForwardNew.js, default.asp, test1.asp, test2.asp and test3.asp. Each page has the script which calls the js page plus the Back & Forward links. I also changed the js array to reflect these files, minus the js script of course. Anyway, if have a suggestion as to what could be the problem, I'd love to hear it.
Here is the BackForwardNew.js file
-------------------------
//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("default.asp","test1.asp","test2.asp","test3.asp");
//The above is all you need to change!
//We want to automatically discover the number of files
NumberOfFiles=database.length;
//Next find out which page, this one is//
//We use the location.href property and extract the filename
//from this string using lastIndexOf:
StringA=location.href;
LengthA=StringA.length
A=StringA.lastIndexOf("/")+1;
ThisFilename=StringA.substring(A,LengthA);
//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:
n=NumberOfFiles-1;
//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)
{
ThisPageNumber=i;
}
}
//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:
else
{top.location=database[ThisPageNumber-1]}}
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:
}
else
{top.location=database[ThisPageNumber+1]}}
//and so that's our code. All we have to do is to change files
//in the Array database! Nice and lazy!
-------------------------
This is in the head of each page which calls the js script.
-------------------------
<script language="JavaScript" scr="BackForwardNew.js">
<!--//
//-->
</script>
-------------------------
This is the code for the back and forward buttons
-------------------------
<a href="javascript:goBack()">Backward</a> <a HREF ="javascript: goForward()">Forward</a>
-------------------------
khalidali63
12-20-2002, 05:12 PM
Just replace same code with the lines below from all of the pages,it should work
<script language="JavaScript1.2" src="BackForwardNew.js"></script>
</head>
<body>
<a href="javascript:goBack();">Backward</a> <a HREF="javascript:goForward();">Forward</a>
skytrekr
12-20-2002, 05:16 PM
Cool. Thanks, I'll try it.