VK wrote:
> stephen@ploughbooksales.com.au wrote:
>
>>I have created an order form that users javascript to create a new html
>>document when the customers clicks the "print page" button.
>>
>>Once the new document has been created it then prints the document and
>>closes it with the following code:
>>
>><body onload="window.print(); window.close();">
>>
>>This works correctly (or at least the way I expect it to work under MS
>>Internet Explorer, but it cuases Netscape to "crash"
>>
>>Does anyone have an explanation as to why?
>
>
> window.print() is not a *process*, it is simply a request to display
> print dialog (same as choosing File > Print). Therefore ideas of sync /
> async are not applicable here.
Maybe that is your opinion based on one browser. The Mozilla DOM
reference says that window.print():
"Prints the current document."
<URL:http://developer.mozilla.org/en/docs/DOM:window.print>
The Netscape Devedge JS Reference says:
"Prints the contents of the window."
<URL:http://devedge-temp.mozilla.org/library/manuals/2000/javascript/1.3/reference/window.html#1203138>
I think the important thing here is that window.print() is DOM 0[1],
and therefore how it works is implementation dependent. You can't
state categorically what it is or does because there is no common
specification that states what it should do, though you might be able
to state what it does in regard to a particular browser.
There are some browsers that don't implement it at all. The best
solution for the OP is to offer a print medium style sheet. If the
browser supports it, it will be used. If not, the window will be
printed as-is.
The use of script in this case is simply not required, there are
already a number of ways to print the page, why add another
(unreliable) method?
1. DOM 0 'refers to a mix (not formally specified) of HTML document
functionalities offered by Netscape Navigator version 3.0 and
Microsoft Internet Explorer version 3.0. In some cases, attributes
or methods have been included for reasons of backward compatibility
with "DOM Level 0".'
<URL:http://www.w3.org/TR/DOM-Level-2-HTML/glossary.html#dt-DOM-Level-0>
[...]
--
Rob
Received on Tue Jan 3 03:54:31 2006