javascript 查找客户端计算机名称

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20676115/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-27 19:00:49  来源:igfitidea点击:

Find a client computer name

javascriptphpcomputer-name

提问by Axeem

I want to find the client computer name. I am using php but it does not work well because it is server side language than I use javascript because it is client side.
I hava a code in javascript but it does not work.

我想找到客户端计算机名称。我正在使用 php,但它不能很好地工作,因为它是服务器端语言,而不是我使用 javascript,因为它是客户端。
我在 javascript 中有一个代码,但它不起作用。

 var network = new ActiveXObject('WScript.Network');  
   alert(network.computerName);  

Why this is not work please tell me.
If javascript can not do that then which language can do that.
Thanks.

为什么这不起作用请告诉我。
如果 javascript 不能做到这一点,那么哪种语言可以做到这一点。
谢谢。

回答by Néstor

@Sachyn Kosare, gethostname is for get local machine name, nor client machine name.

@Sachyn Kosare,gethostname 用于获取本地机器名称,也不是客户端机器名称。

nowadays we will cannot get the client machine name by js due for security reasons and actually activex such as wscript needs clients permissions to run and i don't know if actual IE versions lets run it.

现在,出于安全原因,我们将无法通过 js 获取客户端计算机名称,而实际上诸如 wscript 之类的 activex 需要客户端权限才能运行,我不知道实际的 IE 版本是否可以运行它。