- From: Matthew Raymond <mattraymond@earthlink.net>
- Date: Wed, 20 Jul 2005 14:06:41 -0400
Dean Edwards wrote: > Matthew Raymond wrote: >>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); >>| } > > I mean less practical in terms of memory management. Cloning a document > every time you alter it would likely lead to terrible performance. > Granted, the JavaScript looks slightly neater. Well, we could do something like this: | document.DOMPushState(); | prepareForPrinting(document); | window.print(); | document.DOMPopState(); My concern was that there would be a visual change on the screen just before printing. You could just have it to where redraw is blocked by some mechanism, but what happens if the script crashes and the redraw is never restored? Actually, that above example is effectively this: | prepareForPrinting(document); | window.print(); | restoreForScreen(document); Soooo... Why did we need those events again? (Well, I can think of one single reason: so you don't have a print button to hide in non-CSS browsers. But wait, is that actually a problem??? This is where my inexperience with Javascript rears its ugly head.) Still, we need a way to easily print from an altered DOM without destroying the original DOM state. Cloning seems the safest, most problem free way, but as you say, it initially doubles the memory. Quick Thought: Is there even a real use case for people printing from a non-CSS user agent? If a user agent is sophisticated enough to print, wouldn't it be sophisticated enough to use CSS for the print media? Could someone, for instance, point out a phone that prints out non-styled HTML to a printer?
Received on Wednesday, 20 July 2005 11:06:41 UTC