Home Articles FAQs XREF Games Software Instant Books About Feedback Search Site-Map
irt.org logo

Q1457 Is is possible to have a JavaScript function open an HTML document in a new window and print it without the user having to do anything on the new window?

irt.org | Knowledge Base | JavaScript | Print | Q1457 [ previous next ]

Q1457 Is is possible to have a JavaScript function open an HTML document in a new window and print it without the user having to do anything on the new window?

The user will have to accept the print request, otherwise anyone could print on your printer just by having you visiting their site.

Add this to the bottom of page to be printed:

<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 (window.print) self.print();
else if (navigator.appName.indexOf('Microsoft') !=-1) VBPrint()
setTimeout('self.close()',3000);
//--></script>

and simply have a:

<form>
<input type="button" value="Print Price List" onClick="window.open('pricelist.html','newwin');">
</form>

on the other page.

Feedback on 'Q1457 Is is possible to have a JavaScript function open an HTML document in a new window and print it without the user having to do anything on the new window?'


Provide feedback ...
AddThis Social Bookmark Button

Provide feedback ... AddThis Social Bookmark Button


Last Updated: 30th March 2008. Maintained by: Martin Webb and Michel Plungjan
irt.org liability, trademark, document use, privacy statement and software licensing rules apply.
Copyright © 1996-2008 irt.org, All Rights Reserved.