Tuesday, June 27, 2006

Printing the opposite frame in a frameset

This is just one of those little things you know should be easy, but it isn't... or at least it isn't for you... I have a frameset designed to support the resource that CSL's brilliant indexer puts together for the Public & Special Acts for CT's 2006 Legislative session - http://www.cslib.org/indexing/psindex06.

Anyhow, I simply created a frameset (not because I like them, but) because, for me, it was a "quick & dirty" way to make an alphabetical navigation tool that was permanently visible on the left-hand side... But then I wanted to make it uber-easy to print one frame the main contents of the index (just in case someone is so enamored of the resource that they want it in hard copy).

Since frames can be hard to print from your browser if you're not "in the know", I thought a little script could launch the process for them. After going through a couple of options (at http://www.codelifter.com/main/javascript/printframe.shtml, for example, which did not work since it required me to clear all target = code out of the frames & this screwed up the hyperlinking; and at http://javascript.internet.com/page-details/frame-print.html, which did not work on all browsers - I believe due to its reference to the window. object), I finally figured out how to use a simple button to print one frame from another - uses the top. object). A little form was created and here's what the button's coding looked like:

button type="button" onclick="top.main.focus();
top.main.print();" style="border-style: outset; border-width: 2px"

So, it seems to work in the versions of Firefox, Netscape, and IE that I'm running (which I'll give you are fairly recent). I'm hoping that it's good enough for our users for now ... and that it helps!

No comments: