Go Back   CodingForums.com > :: Client side development > General web building

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rating: Thread Rating: 4 votes, 3.75 average.
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 06-18-2002, 01:55 AM   PM User | #1
kenguild
New to the CF scene

 
Join Date: Jun 2002
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
kenguild is an unknown quantity at this point
Question disabling the Print dialog box

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?
kenguild is offline   Reply With Quote
Old 06-18-2002, 02:03 AM   PM User | #2
ACJavascript
Regular Coder

 
Join Date: Jun 2002
Location: FL, USA
Posts: 734
Thanks: 0
Thanked 0 Times in 0 Posts
ACJavascript is on a distinguished road
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.
__________________
CYWebmaster.com - See why we dot com!!
ACJavascripts.com - Cut & Paste Javascripts!
SimplyProgram.com - Personal Blog
ACJavascript is offline   Reply With Quote
Old 06-18-2002, 03:20 AM   PM User | #3
kenguild
New to the CF scene

 
Join Date: Jun 2002
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
kenguild is an unknown quantity at this point
printer dialog box

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
kenguild is offline   Reply With Quote
Old 06-18-2002, 03:50 AM   PM User | #4
justame
Regular Coder

 
Join Date: Jun 2002
Posts: 676
Thanks: 1
Thanked 0 Times in 0 Posts
justame is on a distinguished road
ken...
does this just a help®???
its from bwuk ...just a nother® great forum member...:O)))

Code:
                    Here's the complete version:
<SCRIPT LANGUAGE="JavaScript">
                    function printit(){ 
                    if (window.print) {
                    window.print() ; 
                    } else if (document.all) {
                    var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0
                    CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
                    document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
                    WebBrowser1.ExecWB(6, 2);//Use a 1 vs. a 2 for a prompting dialog box 
                    WebBrowser1.outerHTML = ""; 
                    }
                    }
                    </script>

                    Then:

                    <a href="#" onclick="printit()">
orrr...
just a thisone® from bwuk n' john...:O)))

Code:
<SCRIPT LANGUAGE="JavaScript">
                    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.');
                    document.close
                    }
                    </script>

It works in IE5+ NS4+
justame is offline   Reply With Quote
Old 06-18-2002, 05:05 AM   PM User | #5
kenguild
New to the CF scene

 
Join Date: Jun 2002
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
kenguild is an unknown quantity at this point
Print box

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?
kenguild is offline   Reply With Quote
Old 06-18-2002, 01:42 PM   PM User | #6
requestcode
Regular Coder

 
Join Date: Jun 2002
Posts: 626
Thanks: 0
Thanked 0 Times in 0 Posts
requestcode is an unknown quantity at this point
Here is an example of justame's code that works for me:
Code:
<html>
<head>
<title>Print Test</title>
<script>
      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 = "";
             }
         else
            {
             window.print();
             }
         }
</script>
</head>
<body>
    <object ID="WebBrowser1" WIDTH="0" HEIGHT="0" 
    CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"> 
    </object>
 <A HREF="#" onClick="Print()">Print this page</a>
</body>
</html>
This is IE only though. For NS browsers you will still get the print box.
requestcode is offline   Reply With Quote
Old 06-18-2002, 02:41 PM   PM User | #7
Zvona
Regular Coder

 
Join Date: May 2002
Location: Helsinki, Finland
Posts: 231
Thanks: 0
Thanked 1 Time in 1 Post
Zvona is an unknown quantity at this point
Curious that :

object.execWB(6,6);
object.execWB(6,-1);

prints without prompting, though MSDN claims

object.execWB(6,2);

shouldn't prompt an user (reference).

Thinking malicious actions (like closing browser without prompting): 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.
__________________
Zvona
First Aid for
Web Design
Zvona is offline   Reply With Quote
Old 06-18-2002, 03:11 PM   PM User | #8
boxer_1
Regular Coder

 
Join Date: May 2002
Location: Maine, USA
Posts: 574
Thanks: 0
Thanked 0 Times in 0 Posts
boxer_1 is an unknown quantity at this point
Quote:
Originally posted by Zvona
Thinking malicious actions (like closing browser without prompting): 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 .
__________________
boxer_1
CodingForums Moderator
"How did a fool and his money get together in the first place?"

Last edited by boxer_1; 06-18-2002 at 03:13 PM..
boxer_1 is offline   Reply With Quote
Old 06-18-2002, 05:53 PM   PM User | #9
kenguild
New to the CF scene

 
Join Date: Jun 2002
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
kenguild is an unknown quantity at this point
Cool printin

Thank you guys so much for your help! the last script worked great! You really saved my butt! thanks again KG

Sorry about the cross posting Z!
kenguild is offline   Reply With Quote
Old 06-19-2002, 08:38 AM   PM User | #10
Zvona
Regular Coder

 
Join Date: May 2002
Location: Helsinki, Finland
Posts: 231
Thanks: 0
Thanked 1 Time in 1 Post
Zvona is an unknown quantity at this point
Angry

Actually I made a code yesterday, which will print a picture ( not XXX, though ) 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.
__________________
Zvona
First Aid for
Web Design

Last edited by Zvona; 06-19-2002 at 08:44 AM..
Zvona is offline   Reply With Quote
Old 08-23-2002, 12:19 PM   PM User | #11
JeanValJean
New to the CF scene

 
Join Date: Aug 2002
Location: Asia
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
JeanValJean is an unknown quantity at this point
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 : )
__________________
I am not an english native speaker.
If i don't express clearly,please bear with me.THANK YOU :)
JeanValJean is offline   Reply With Quote
Old 05-12-2005, 10:09 PM   PM User | #12
Aaronn
New to the CF scene

 
Join Date: May 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Aaronn is an unknown quantity at this point
Suppress print dialog w/XP

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.

Thanks,
Aaron.
Aaronn is offline   Reply With Quote
Old 05-13-2005, 01:35 AM   PM User | #13
Basscyst
Smokes a Lot


 
Join Date: Jul 2003
Location: CA, USA
Posts: 1,594
Thanks: 5
Thanked 20 Times in 20 Posts
Basscyst is on a distinguished road
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.

Basscyst
__________________
Helping to build a bigger box. - Adam Matthews
Basscyst is offline   Reply With Quote
Old 05-13-2005, 05:56 PM   PM User | #14
oracleguy
Rockstar Coder


 
Join Date: Jun 2002
Location: USA
Posts: 9,043
Thanks: 1
Thanked 322 Times in 318 Posts
oracleguy is a jewel in the roughoracleguy is a jewel in the roughoracleguy is a jewel in the rough
Quote:
Originally Posted by Basscyst
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.

Basscyst
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.
__________________
OracleGuy
oracleguy is offline   Reply With Quote
Old 07-21-2005, 06:23 PM   PM User | #15
eurka
New to the CF scene

 
Join Date: Jul 2005
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
eurka is an unknown quantity at this point
what a great script Mr requestcode

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

regards

eurka@next.jo
eurka is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 02:46 AM.


Advertisement
Log in to turn off these ads.