You are here: irt.org | FAQ | JavaScript | Frame | Q534 [ previous next ]
Interrogate the locations href property of the other frame then depending on the filename change the location:
<script language="JavaScript"><!--
function getpagenumber() {
var otherpage = parent.otherFrameName.location.href;
var pagenumber = otherpage.substring(otherpage.length-3,otherpage.length);
return pagenumber - 0;
}
function goForward() {
var page = getpagenumber();
if (page < 100)
parent.otherFrameName.location.href = 'file_' + pad(page + 1,3);
}
function goBackward() {
var page = getpagenumber();
if (page != 1)
parent.otherFrameName.location.href = 'file_' + pad(page - 1,3);
}
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>