Solved

Disable Printer Dialog Box when Printing

Posted on 2001-08-14
6
737 Views
Last Modified: 2007-12-19
Is there any to print from a web page without displaying the printer dialog box.
The company security settings hide the printer settings, so when users try printing from IE an error occurs because the printer dialog box cannot be displayed.
I need to bypass the printer dialog box.
0
Comment
Question by:Scamp
  • 3
  • 2
6 Comments
 
LVL 8

Accepted Solution

by:
drittich earned 200 total points
Comment Utility
You can use this JavaScript function:

function printit(){
    if (NS) {
        window.print() ;
    } else {
        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 = "";
    }
}

And call it with a button like this:

<input type=button value="Print" onClick="printit()">

0
 
LVL 8

Expert Comment

by:drittich
Comment Utility
Try this instead:


<html>
<head>
<title></title>
<script language="javascript">
function printit(){
   if (NS) {
       window.print() ;
   } else {
       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>

</head>
<body>
some text to be printed...<br>


<SCRIPT Language="Javascript">
var NS = (navigator.appName == "Netscape");
var VERSION = parseInt(navigator.appVersion);
if (VERSION > 3) {
    document.write('<form><input type=button value="Print this Page" name="Print" onClick="printit()"></form>');
}
</script>
</body>
</html>


0
 

Author Comment

by:Scamp
Comment Utility
Thankyou very much Drittich - works brilliantly!
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 20

Expert Comment

by:jitganguly
Comment Utility
Guys,
Just curious, is that compatible to NN also ?
0
 
LVL 8

Expert Comment

by:drittich
Comment Utility
Umm, not sure.
0
 
LVL 20

Expert Comment

by:jitganguly
Comment Utility
I don't think. and that was my problem
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video discusses moving either the default database or any database to a new volume.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now