faqts : Computers : Programming : Languages : JavaScript

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

19 of 36 people (53%) answered Yes
Recently 5 of 10 people (50%) answered Yes


Using windows.print() causes computer to hang. Any help will be appreciated.

Apr 6th, 2008 19:24
ha mo, Colin Fraser, Wayne Sinclair, Martin Honnen

If you are using 
Then it is little wonder that things are not working, try 
That may help, a simple typo will cause some problems, but I would not
have thought that it would cause the computer to hang. 
There is another problem here, I suspect, and that is you are trying to
get  IE to print using a javascript, so an error occurs. Typically,
Microsoft's management of Javascript is poor, favouring their own ideas
over anyone elses, so you may want to use a VB Script instead. 
I pinched this from Martin Honnen a long time ago, and just adapt it to
my own immediate need when required : 
<object id="WBControl" width="0" height="0"
<script language="VBScript"><!--
Sub VBPrint() On Error Resume Next
  WBControl.ExecWB 6,1
    from memory, not having used this for ages, I think that this last 
    line may also use 
          WBControl.ExecWB 6,0 
    to stop the print confirm dialogue box from opening and annoying
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>');
Test this out, I know it works when I have used it, but it may take a
little while for you to figure it out. It wont take long, and you may be
pleasantly surprised by what you learn while doing it.