Can I have JavaScript select printer to use?

Kris picture Kris · Oct 25, 2011 · Viewed 10.3k times · Source

Possible Duplicate:
Printing to a specific printer from a web app

One of our intranet applications needs to print out to a non-default printer. Of course people regularly forget to select the correct printer.

I'm aware that you can not do this normally via JavaScript but given that the browser is IE9 and I can add the webapp to the trusted zone (and fiddle around with the security settings at will), is there any way to write JavaScript that will automatically select the correct printer? Perhaps using some ActiveX or other IE specific stuff.

Answer

isJustMe picture isJustMe · Oct 25, 2011

No, the Javascript object model includes a window.print() method that may activate the standard print dialogue of a Web browser, but that is as far as the functionality extends. It would not be appropriate or safe for Javascript code to be able to check the printers attached to a computer, look up printer properties or arbitrarily configure their settings.

I suggest to add a pop prior to printing where you remind the user to select the appropiate printer.