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

Q930 How can I print all the frames in a frameset?

You are here: irt.org | FAQ | JavaScript | Print | Q930 [ previous next ]

Iterate through each frame, checking for other frames, if none are found, print the frame:

<script language="JavaScript"><!--
function printAll(where) {
    if (where.frames.length == 0)
        where.print();
    else
        for (var i=0;i<where.frames.length;i++)
            printAll(where.frames[i]);
}

if (window.print) {
    document.write('<form><input type="button" onClick="printAll(top)" value="Print Frames"><\/form>');
}
//--></script>

To test this out - without destroying a rain forest - change:

where.print();

to:

alert(where.location.href);

This will then alert the location of each frame in the entire frameset.

Feedback on 'Q930 How can I print all the frames in a frameset?'

©2018 Martin Webb