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?

9 of 23 people (39%) answered Yes
Recently 3 of 10 people (30%) answered Yes


how to capture the print dialog box and customize the options in javascript (print 2 copies etc..)?

Apr 7th, 2008 23:06
ha mo, Colin Fraser, vrushali nadpurohit,

I am not sure exactly what you are after here, but I can take a stab at it. 
Firstly, I am not sure that you can send parameters to the printer and
bypass the print dialog. However, one thing you can try is : 
function noDialog(numcopy) {
var i = 1;
for (i; i==numcopy; i++) {
 if ((navigator.appName == "Netscape")) {
   window.print() }
 else {
  var mybrowser = "<OBJECT ID='brwsr' WIDTH=0 HEIGHT=0
  document.body.insertAdjacentHTML('beforeEnd', mybrowser);
  brwsr.ExecWB(6, -1)
} //for
<form name="prnform">
How many copies: <input type="text" name="prnumber">
<input type="button" onClick="javascript:noDialog(this.prnumber.value)">
I am pretty sure I got this working, ages ago, it should work now but I
had a lot of problems in IE 5 with this, from memory and evetually gave
it up as a bad loss. Then I recall seeing that it wont work in anything
less than IE 5.5. I am also sure I posted this solution, or something
like it, here once before, and there was an issue with the dialog, the
-1 turns it off or on or something. Sorry, I cannot remember.