[whatwg] [html5] onbeforeprint/onafterprint (was window.print() undefined)

Matthew Raymond mattraymond at earthlink.net
Wed Jul 20 09:34:49 PDT 2005

Anne van Kesteren wrote:
> Quoting Matthew Raymond <mattraymond at earthlink.net>:
>>6) An alternative has been proposed that has less potential for abuse,
>>is more powerful, and doesn't change basic browser functionality.
> Which alternative was proposed that did not rely on CSS and is acceptable?
> (Also, the alternative probably won't work in existing browers...)

   The one I've been pushing for the last few days: allow scripting to
create a copy of the document, manipulate the copy, and print from the
copy. That way, the app will just have a button that says "Print High
Quality Version" or something, and a script clones the document, makes
the appropriate changes, and prints it. When you press the button again
(because you forgot you wanted two copies), the script can detect that
no changes have been made and simply use the last cloned document object:

| if (documentchanged) {
|   printClone = document.clone();
|   prepareForPrinting(printClone);
| }
| printClone.print();

   Hmm, that prints from the document object instead of the window,
though. Is there a better way to implement this?

   The general idea, though, is that when I print a web page, I want to
print a web page, not some altered version of the web page a webmaster
sees fit to allow me to print. Specific print version should be handled
by UI in the page itself. (Or perhaps with a <link> element.)

More information about the whatwg mailing list