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.