Home Articles FAQs XREF Games Software Instant Books About Feedback Search Site-Map
irt.org logo

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

irt.org | Knowledge Base | JavaScript | Print | Q930 [ previous next ]

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

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


Provide feedback ...
AddThis Social Bookmark Button

Provide feedback ... AddThis Social Bookmark Button


Last Updated: 30th March 2008. Maintained by: Martin Webb and Michel Plungjan
irt.org liability, trademark, document use, privacy statement and software licensing rules apply.
Copyright © 1996-2008 irt.org, All Rights Reserved.