Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

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?

You are here: irt.org | FAQ | JavaScript | Print | Q1457 [ previous next ]

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?'

©2018 Martin Webb