Online Shopping : Computers : Programming : Languages : JavaScript

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

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

Entry

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"
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><!--
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>');
}
//--></script>
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
statement. 
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...
http://www.businessian.com
http://www.computerstan.com
http://www.financestan.com
http://www.healthstan.com
http://www.internetstan.com
http://www.moneyenews.com
http://www.technologystan.com
http://www.zobab.com
http://www.healthinhealth.com