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: Jon Hanna <jon@spinsol.com>
Date: Thu, 10 Jan 2002 14:55:53 -0000
To: "WAI Interest Group" <w3c-wai-ig@w3.org>
Hash: SHA1

> We wanted to
> add a "Print" button to make it clearer, but that turns out to
> require JavaScript to work, and we were aiming for WAI Pri. 1.

Not only does it need javascript to work, but it also needs to has to
be on a subset of those browsers with javascript - many will error if
you try to run the print command.
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

This works because self.print returns either a function reference or
nothing depending whether printing is available, which gets cast to
true of false respectively.

It will print on NS4+ and IE5+, I don't know about the other browsers
(there is a really weird way of printing from js in IE4, but unless
you have a strong need to allow IE4 to print as well you are better
off leaving alone). On the other browsers you've done no harm, so no
WAI violation.

Version: PGPfreeware 6.5.3 for non-commercial use <http://www.pgp.com>

Received on Thursday, 10 January 2002 09:56:12 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 20:36:06 UTC