|
Q534 I have a large list of html files, file_001 onwards, how can I make forward/back buttons in one frame that move through the files in another?
irt.org | Knowledge Base | JavaScript | Frame | Q534 [ previous next ]
Q534 I have a large list of html files, file_001 onwards, how can I make forward/back buttons in one frame that move through the files in another?
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>
|
Feedback on 'Q534 I have a large list of html files, file_001 onwards, how can I make forward/back buttons in one frame that move through the files in another?'
|
|
Copyright © 1996-2008 irt.org, All Rights Reserved.