Get default printer name from javascript?

房东的猫 提交于 2019-12-11 06:48:18

问题


Is it possible to fetch the name of default printer from javascript? I need only the name of the printer and display a dialogue asking the user to manually change his default printer, if the default printer doesn't meet my appliation requirement. Im using plain javascript


回答1:


In "plain" javascript this is not possible. Please add more details to your question if you're using some HTML5-ish related API.




回答2:


This is not possible.

Related: Disabling browser print options (headers, footers, margins) from page?

You can of course change the layout of the printed page using @media print { ... } in your stylesheets or using media='print' in your link element.




回答3:


You may use flash or Java applets or silverlight to identify the default printer name. It works only if the client has those plugins.

Alternate, You can access it using ActiveXObject(). But a big note: Its IE Specific. It depends on the users of your site. Even VBScript would work for IE browsers.




回答4:


var oShell = new ActiveXObject("WScript.Shell");
sRegVal = 'HKEY_CURRENT_USER\\Software\\Microsoft\\Windows NT\\CurrentVersion\\Windows\\Device';

var sName = oShell.RegRead(sRegVal)

From: codeproject: how to get the client printer name using javascript



来源:https://stackoverflow.com/questions/12565880/get-default-printer-name-from-javascript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!