W3C home > Mailing lists > Public > w3c-wai-ig@w3.org > January to March 2002

Re: Using Form Elements for Pages only Intended for Printing

From: Jim Ley <jim@jibbering.com>
Date: Thu, 10 Jan 2002 15:04:30 -0000
Message-ID: <020b01c199e8$1b0bb8e0$ca969dc3@emedia.co.uk>
To: "WAI Interest Group" <w3c-wai-ig@w3.org>
 "Jon Hanna" <jon@spinsol.com>

> However, all is not lost, the following will only appear on those
> browsers which allow printing via javascript:
>
> Put this where the button or link should be:
>
> <script type="text/javascript" src="print.js"></script>
>
> print.js is as follows:
>
> if (self.print){
> document.write('<div><a href="javascript:self.print();">Print This
> Page</a></div>')
> }

Well it's better (but having it as an external script seems very
wasteful.) but it's still not perfect, you're now assuming the
javascript: pseudo protocol exists, which is unwarranted, also why have
the DIV?

if (window.print) {
 document.write('<a href="somepage.html" ')
 document.write('onclick="if (window.print) window.print(); return
false">')
 document.write('Print this page</a>')
}

Where sompage.html is meaningful as it can still fail in a number of
(rare) scenarios.

Jim.
Received on Thursday, 10 January 2002 10:06:14 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 19 July 2011 18:14:00 GMT