[WEB4LIB] Print Page & E-Mail This Page (functions)...

Thomas Dowling tdowling at ohiolink.edu
Fri Sep 22 09:23:30 EDT 2000


> I'm looking to add two types of functionality to a Web site... and would
be
> interested if anyone here knows of a good Javascript or CGI solution for
> these:
>
> * Print This Page (formats for printer-friendly/or just print)

This may not directly answer your question, but it's a handy little trick
I've been using more and more.

CSS allows authors to specify different stylesheets for different media,
and browsers that are at all current on their CSS support (IE, Opera,
Mozilla) understand at least the "print" and "screen" media:

  <link rel="stylesheet" type="text/css" href="print.css" media="print">
  <link rel="stylesheet" type="text/css" href="standard.css"
media="screen">

Opera also understand the "projection" medium presentations and uses it in
full-screen mode.

If you have navigational buttons, etc. that don't make sense in print
output, you can stick them inside a DIV or TD with a class name like
"OnscreenNav".  Then in the print stylesheet, define ".OnscreenNav
{display: none}".  For supporting browsers, this content will appear as
expected onscreen, but will not be included in the output.  Note that it
should be possible to do this all in one stylesheet, but I haven't
experiemented enough to know about browser support for that.

To be bug-compatible with NN4, you should put the print stylesheet first
in your document head and make sure the standard stylesheet includes
".OnscreenNav {display: block}" (or "display: inline" depending on your
markup--you may need to define more than one class with properties set in
each stylesheet).  NN4 will print the page the way it displays it, as will
non-CSS browsers.

<URL:http://www.w3.org/TR/REC-CSS2/media.html> for details.

Thomas Dowling
OhioLINK - Ohio Library and Information Network
tdowling at ohiolink.edu




More information about the Web4lib mailing list