View Full Version : disabling the Print dialog box

06-18-2002, 02:55 AM
I am creating a stand alone web page for a kiosk and want to print out coupons. I have a script that will print the page or coupon but I keep getting the print dialog box coming up when I hit the print button. Is there a way to disable this box or tell the page which printer to print to?

06-18-2002, 03:03 AM
If your talking about the dialog box that sets the printers paper, caulity, ink, ect. I don't think that can be removed. Thats part of the computer so i don't think there are any scripts that can do that. :D:D:D

06-18-2002, 04:20 AM
It does not happen when I click on the printer icon in the tool bar though that is why I am wondering how to get that code

06-18-2002, 04:50 AM
does this just a help®???
its from bwuk ...just a nother® great forum member...:O)))

Here's the complete version:
function printit(){
if (window.print) {
window.print() ;
} else if (document.all) {
var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0
document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
WebBrowser1.ExecWB(6, 2);//Use a 1 vs. a 2 for a prompting dialog box
WebBrowser1.outerHTML = "";


<a href="#" onclick="printit()">

just a thisone® from bwuk n' john...:O)))

if (window.print) {
document.write('Please PRINT this page for later reference '
+ '<form><input type=button name=print value="Print" '
+ 'onClick="javascript:window.print()"><\/form> Have Great Day.');

It works in IE5+ NS4+

06-18-2002, 06:05 AM
No they did not work I get script errors on the second one. Maybe I am not putting in the correct variables in the first one?

06-18-2002, 02:42 PM
Here is an example of justame's code that works for me:

<title>Print Test</title>
function Print()
if (document.all)
WebBrowser1.ExecWB(6, 6) //use 6, 1 to prompt the print dialog or 6, 6 to omit it;
WebBrowser1.outerHTML = "";
<object ID="WebBrowser1" WIDTH="0" HEIGHT="0"
<A HREF="#" onClick="Print()">Print this page</a>

This is IE only though. For NS browsers you will still get the print box.

06-18-2002, 03:41 PM
Curious that :


prints without prompting, though MSDN claims


shouldn't prompt an user (reference (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/com/oen_a2z_5k38.asp?frame=true)).

Thinking malicious actions (like closing browser without prompting (http://www24.brinkster.com/zvona/htmlexa.asp?article=04)): what if someone prints material I don't want to print (eg adult) for me? This action could be done without me noticing it at all.

06-18-2002, 04:11 PM
Originally posted by Zvona
Thinking malicious actions (like closing browser without prompting (http://www24.brinkster.com/zvona/htmlexa.asp?article=04)): what if someone prints material I don't want to print (eg adult) for me? This action could be done without me noticing it at all.

True, I could also see some other potential annoying/unethical uses for scripts bypassing the print dialog box....Printing unwanted Ads for example. I realize that Kenguild has perfectly valid intentions/reasons for wanting the script, so it really doesn't apply to to his/her question and intended purpose.

However, I believe that simply having to click 'OK' to to complete the printing of a page is a small price to pay to allow the user to control whether the printing occurs or not. I do realize that in the examples here the user would have to click a "Print Page" link to initiate the print, which they would obviously not do if they didn't want to print the page. But with a few modifications, this could all be changed, such as calling the function onLoad or disguising the link that calls the funtion (Ex: <a href="#" onClick="Print();">Back to top</a>).

Just some thoughts/add-ons to Zvona's reply I guess ;).

06-18-2002, 06:53 PM
Thank you guys so much for your help! the last script worked great! You really saved my butt! thanks again KG :D

Sorry about the cross posting Z!

06-19-2002, 09:38 AM
Actually I made a code yesterday, which will print a picture ( not XXX, though :rolleyes: ) without user knowing it. This code will be executed automatically on Outlook Express (hello MS) and all other e-mail clients, which happens to parse HTML. (There's a way to "mask" every line from script to make e-mail clients to think they parse only pure HTML).

Wouldn't be nice to use this kind of mail eg. for spamming or in newsgroups. I'd say it wouldn't take much time when printer trays would be out-of-paper in larger companies.

Edit :
No problemo with cross-posting, Ken.

Most of members reads nearly every forum, so a professional answer to every single problem are posted in no time. Thus, there's no need for cross-posting in expectation of getting more answers and faster.

08-23-2002, 01:19 PM
in need of help, I have a extended question:
Can I controll the functions in the printer dialog box?
for example, when people printing my web pages ,
I want to provide 2 options for them ,
"print in color" and "print in black and white"
Can this become possible?

farther more...
Can I controll the IE functions ,like print with/without BG color?

these are my questions THANKS : )

05-12-2005, 11:09 PM
Has anyone tried using this technique to suppress the print dialog using windows XP? I have tried using ExecWB(6,-1), ExecWB(6,1), ExecWB(6,2), ExecWB(6,6). Anyway I always get the print dialog on XP. -1 works fine on NT systems.


05-13-2005, 02:35 AM
Ha, I got all excited to (try and) read a justame post again. Sadly this is just old. :(

Sorry, off topic but I had to comment.


05-13-2005, 06:56 PM
Ha, I got all excited to (try and) read a justame post again. Sadly this is just old. :(

Sorry, off topic but I had to comment.


Lol, I know I was excited too and then i looked at the date.

I'd imagine why you can't get it to be supressed in XP is all the new security features they threw in with SP2. Since if you can supress that dialog using a script it is "technically" malicious thing.

07-21-2005, 07:23 PM
Sir requestcode

is there a way to chane the print this page with

a word.doc that i have , i mean that i have a word

document i want to print as the same way with

no print dialg box . so when i press a button my

word document prit.doc print direct to the printer

if you can please help , i'am loooking weeks for

the code that you write ( the great script ) please

if you can give me the one can print a word doc

not the curent page the html view ,

thank you again



07-22-2005, 02:33 PM
Any comment please ?

07-27-2005, 01:05 PM
up up up up up up up up up up up
:) :rolleyes: :cool: :p ;) :D

06-22-2007, 04:07 PM
Hi to all,

I use ObjectBrowser control with ExecWB method to print Word .doc files from I.E. and it's gone all well since I use WIN 2000 as client S.O. But when I passed to WIN XP, for client S.O., the printing result is a blank page with only IE header and footer. Why?

Does anybody have an answer?

Thank you in advance.