Online Shopping : Computers : Programming : Languages : JavaScript

+ Search
Add Entry AlertManage Folder Edit Entry Add page to
Did You Find This Entry Useful?

12 of 14 people (86%) answered Yes
Recently 9 of 10 people (90%) answered Yes


I'm looking for a print button that works in IE, Netscape AND opera 5.0. Is this possible?

Apr 6th, 2008 19:40
ha mo, Colin Fraser, w. keijzers,

IE requires different script to NN and Opera. I understand that Opera is
far more closely related to Mozilla, therefore NN, than IE, and it wil
respond to the same events and functions as NN. 
Try this 
<object id="WBControl" width="0" height="0"
<script language="VBScript"><!--
Sub VBPrint() On Error Resume Next
  WBControl.ExecWB 6,-1
End Sub
<script language=JavaScript><!--
if (self.print)
  document.write('<A HREF="javascript:;" language="JavaScript"
onClick="self.print(); return false;">print</a>');
else {if (navigator.appName.indexOf('Microsoft') != -1)
  document.write('<a href="javascript:;" language="JavaScript"
onClick="VBPrint(); return false;">print</a>');
IE does not always respond to the (self.print) function, so if it does
not then it will use the "else if", the key of course is the object
statement. You may want to use something else as the boolean for the if
I have it on good authority that it works, although I have never used it
myself, I dont believe in cutting down trees for paper when we don't
really need to. btw, the "-1" in the Sub VBPrint apparently turns off
the print alert dialogue box. I am not sure where I got this code from,
but it will work.
Good luck...