Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

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?

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>

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?'

©2018 Martin Webb