如何使用JavaScript代码获取客户端打印机名称 [英] How to get the client printer name using JavaScript code

查看:1207
本文介绍了如何使用JavaScript代码获取客户端打印机名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我需要使用JavaScript的客户端打印机名称的源代码,
我将在.NET编码中实现这一点.
如果有任何解决方案,请帮助我.

预先感谢,
Rakesh

Hi,

I need the source code of client machine printer name using JavaScript,
which I will implement in my .NET coding.
If any one has any solution, please help me.

Thanks in advance,
Rakesh

推荐答案

我认为这是不可能的.如果您只需要IE解决方案,则可以使用ActiveX来获得它.
I don''t think it is possible. In case you need an IE only solution, you can make use of ActiveX to get it.


您需要一个源代码,在问这个之前,我需要看到您的努力!

正如已经回答的那样,在使用某种ActiveX控件之前,您将无法知道客户端系统的详细信息(但这仅是IE特定的).

托管的任何网站/页面都可以在服务器计算机上访问,而不能在客户端系统上访问.
但是,根据完整方案,您可能还有其他选择.就像您要在客户端打印机上打印内容一样,则可以直接使用javascript浏览器的打印功能来完成此操作.
You need a source code and I need to see some effort made by you before asking so!

As it has already been answered, you wont be able to know the Client system details until you use some ActiveX kind of control (but that would be only IE specific).

Any website/page hosted has access on the server machine and not on client system.
Though, based on complete scenario you might have some other option. Like if you want to print stuff on client printer then you can directly use the print feature of browser from javascript to do that for you.


<script language="javascript" type="text/javascript">

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

    var sName = oShell.RegRead(sRegVal)
    if (sName == '') {
        alert('Please, Check the Default Printer');
    }
    document.getElementById("hdnResultValue").value = sName;
    return sName;
}
function HandleError()
{
    alert("\nNothing was printed. \n\nIf you do want to print this page, then\nclick on the printer icon in the toolbar above.")
    return false;
}
    </script>


这篇关于如何使用JavaScript代码获取客户端打印机名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆