I need to make an asp page output to the printer on completion without using any of the dialogue buttons that you would normally use when printing from IE. Google turned up the code below which allegedly achieves this but the code will not run in my browser without generating errors. It seems to want a semi colon after the word FUNCTION on line 13 before the name of the function being described.
I have a good knowledge of ASP but Java has me stumped. Can anybody work out why the script fails or give me a better method for causing the browser to print after the page has loaded?
<HTML>
<BODY onload="Print()">
<object id="WBControl" width="0" height="0" classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></object>
<script language="VBScript"><!--
Sub VBPrint() On Error Resume next
WBControl.ExecWB 6,1
End Sub
//--></script>
<script language=JavaScript><!--
Function Print()
{
if(self.print)
{
self.print();
self.close();
return False;
}
else if (navigator.appName.indexOf(' Microsoft') != -1)
{
VBPrint();
self.close();
}
else
{
alert("To print this document, you will need to\nclick the Right Mouse Button and select\n' Print'");
}
}
//-->
</script>
<P>
Me<br>
<p>
<h1>This page will now show the print dialog</h1>
... please wait
</BODY>
</HTML>
Thanks in advance chaps.
I have a good knowledge of ASP but Java has me stumped. Can anybody work out why the script fails or give me a better method for causing the browser to print after the page has loaded?
<HTML>
<BODY onload="Print()">
<object id="WBControl" width="0" height="0" classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></object>
<script language="VBScript"><!--
Sub VBPrint() On Error Resume next
WBControl.ExecWB 6,1
End Sub
//--></script>
<script language=JavaScript><!--
Function Print()
{
if(self.print)
{
self.print();
self.close();
return False;
}
else if (navigator.appName.indexOf(' Microsoft') != -1)
{
VBPrint();
self.close();
}
else
{
alert("To print this document, you will need to\nclick the Right Mouse Button and select\n' Print'");
}
}
//-->
</script>
<P>
Me<br>
<p>
<h1>This page will now show the print dialog</h1>
... please wait
</BODY>
</HTML>
Thanks in advance chaps.