Almost working - need a little help

C

Chris

I have a script that will navigate back and foreward using a form. The
files it navigates are named: bg1.html, bg2.html, bg3.html, etc.

This is happening in a frameset, where my BACK and FORWARD buttons are
in one frame, and the content pages are in another (main).

I can get read the current page location in the frame "main", but it
is not working (getpagenumber)- it should give the current page
number, and use that number to tell the rest of the script where Back
and Foreward is. The current page is "bg1.html"

My script is below, followed by the form that will use it. Any help or
advice would be appreciated:

<script language="JavaScript">
<!--
function getpagenumber() {
var otherpage = parent.main.location.href;
var pagenumber =
otherpage.substring(otherpage.length-3,otherpage.length);
return pagenumber - 0;
}

function goForward() {
var page = getpagenumber();
if (page < 100)
parent.main.location.href = 'bg' + pad(page + 1,3) + '.html';
}
function goBackward() {
var page = getpagenumber();
if (page > 1)
parent.main.location.href = 'bg' + pad(page - 1,3) + '.html';
}
function pad(number,length) {
var str = '' + number;
while (str.length < length)
str = '0' + str;
return str;
}
//--></script>




<form>
<input type="button" value="Back" onClick="goBackward()">
<input type="button" value="Forward" onClick="goForward()">
</form>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,135
Latest member
VeronaShap
Top