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

Matthew Raymond mattraymond at earthlink.net
Wed Jul 20 10:12:03 PDT 2005


Dean Edwards wrote:
> Matthew Raymond wrote:
>>| if (documentchanged) {
>>|   printClone = document.clone();
>>|   prepareForPrinting(printClone);
>>| }
>>|
>>| printClone.print();
> 
> This seems less practical than print events.

   I don't see how:

| OnBeforePrintEventFunction() {
|   prepareForPrinting(document);
| }
|
| OnAfterPrintEventFunction() {
|   restoreForScreen(document);
| }

   With my method, you don't have to worry about restoring anything,
because you can just get rid of the clone once you're done printing.

> It is also very difficult to detect changes to the document.

   Perhaps. Depends on the application.

> What do you mean by changes? Style
> changes? New/removed content?
> 
> I quite like the idea of a DOMModified event. Does this exist? Can we 
> have it please?

   I think the DOM spec already has events that fire when you alter the
DOM. Here's some DOM notes I took regarding unimplemented DOM stuff in
Mozilla...

| DOM2
| - Events for interface MutationEvent
| -- DOMSubtreeModified
| -- DOMNodeRemovedFromDocument
| -- DOMNodeInsertedIntoDocument

   I don't think IE supports that either, or Opera for that matter.



More information about the whatwg mailing list