Some people often ask questions about Printing web pages, although many of them know window. print () can implement the printing function, but the function is not completely enough. The following example will show you how to implement the complete printing Control Technology:
<HTML>
<Head>
<Script language = "JavaScript">
<! --
DA = (document. All )? 1: 0
Window. onerror = handle_error
Function handle_error ()
{
MSG = "\ n no Dongdong print. \ n if you want to print this page ,"
MSG + = "and \ n click the print button on the toolbar ."
Alert (MSG)
Return true;
}
// -->
</SCRIPT>
<Script language = "VBScript">
Sub print
Olecmd = 6' print command
Oleparam = 1
On Error resume next
Printit. execwb olecmd, oleparam
If err. Number <> 0 then
If Da Then 'ie4 user will exit Printing
Alert "Printing failed ."
The user of else 'ie3 will execute handle_error to handle the error.
Handle_error
End if
End if
End sub
</SCRIPT>
</Head>
<Body>
<Form>
<Input type = button value = "print" onclick = "window. Print ();">
</Form>
<Object ID = "printit"
Width = 0 Height = 0
Classid = "CLSID: 8856f961-340a-11d0-a96b-00c04fd705a2">
</Object>
</Body>
</Html>