stockton Posted July 7, 2008 Share Posted July 7, 2008 I have an application running on Windows XP & IE7 which currently displays a screen of information and then uses javascript self.print(); to print same to locally connected printer. Two things wrong with this and they are:- 1) I want my application to print directly to the default printer without the Windows select printer dialog coming up and 2) I really dont need to display the screen. All the user wants is a printout, receipt. Suggestions please. Quote Link to comment Share on other sites More sharing options...
stockton Posted July 7, 2008 Author Share Posted July 7, 2008 Would it make any difference if I used something other than JavaScript? VBScript? Java? Quote Link to comment Share on other sites More sharing options...
rhodesa Posted July 7, 2008 Share Posted July 7, 2008 Not possible via a web browser. The user HAS to click print on the dialog. (sorry to be the barer of bad news) :-\ Quote Link to comment Share on other sites More sharing options...
stockton Posted July 7, 2008 Author Share Posted July 7, 2008 Sorry, I did not explain myself clearly enough. The user has already on a previous screen clicked print. Quote Link to comment Share on other sites More sharing options...
rhodesa Posted July 7, 2008 Share Posted July 7, 2008 Sorry, I did not explain myself clearly enough. The user has already on a previous screen clicked print. Clicked "print" as in your button on your webpage? All you can do is help them by bringing up the dialog. You can't skip the Window's print dialog. If you are looking to do something like Google Maps, where they have a print button, which when clicked brings up a new webpage window, and once the new webpage is loaded, it automatically shows the print dialog, just add this between your HEAD tags on your popup: <script type="text/javascript"> window.onload=function(){window.print()}; </script> Quote Link to comment Share on other sites More sharing options...
stockton Posted July 8, 2008 Author Share Posted July 8, 2008 The thing that is confusing me is that there is a C# application on the client(this is an intranet) that prints directly to the default printer without involving the Window's print dialog and the user want their webapp to do the same. Quote Link to comment Share on other sites More sharing options...
rhodesa Posted July 8, 2008 Share Posted July 8, 2008 The C app runs in a COM environment, which has access to print things directly. You're web app runs in a browser, which restricts that. The reason: With a C app, the person should know what the program does before running it. But with a web app, people browsing the web can come across any site. If the browser allowed websites to auto-print without prompting, I could code my site to print thousands of pages of garbage whenever someone visited it. That wouldn't be very good would it? Now, the SERVER hosting the webapp could automatically print stuff by executing some server side code (PHP or C or something). But not the client. Quote Link to comment Share on other sites More sharing options...
stockton Posted July 8, 2008 Author Share Posted July 8, 2008 Thank you. Now I understand a little better. Quote Link to comment Share on other sites More sharing options...
jkeen71 Posted October 16, 2009 Share Posted October 16, 2009 I wanted to send my thanks to rhodesa for the explanation and ask question again considering any new developments and capabilities through php integration with javascript or ActivX. I understand the limitation & concern but there is still a legitimate need for quickly printing an html report that is generated on click of a button and sent to the pre-defined default printer on client side while bypassing the print dialog. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.