admin管理员组

文章数量:1293239

Example:

<script type = "text/JavaScript">
try
{
var ax = new ActiveXObject("WScript.Network");
document.write('User: ' + ax.UserName + '<br />');
document.write('Computer: ' + ax.ComputerName + '<br />');
}
catch (e)
{
document.write('Permission to access puter name is denied' + '<br />');
}
</Script>

Actually I am Getting the Following output:

Permission to access puter name is denied

Please help to get Client Machine Computer name using jquery / Javascript (Php).

Example:

<script type = "text/JavaScript">
try
{
var ax = new ActiveXObject("WScript.Network");
document.write('User: ' + ax.UserName + '<br />');
document.write('Computer: ' + ax.ComputerName + '<br />');
}
catch (e)
{
document.write('Permission to access puter name is denied' + '<br />');
}
</Script>

Actually I am Getting the Following output:

Permission to access puter name is denied

Please help to get Client Machine Computer name using jquery / Javascript (Php).

Share Improve this question edited Jan 20, 2016 at 21:39 patricksweeney 4,0227 gold badges44 silver badges56 bronze badges asked Dec 17, 2015 at 6:41 Dinesh GDinesh G 1,3655 gold badges17 silver badges24 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 4

The problem is explained in the following Link. They say it is (in most cases) impossible to do.

However, if you are making an internal application you can 'register' each puter to a database and save the putername and IP. And then you can later use the IP of the host to determine the hostname by querying it to the database.

ActiveX is a Microsoft-proprietary framework.Your code works only in IE. In other browsers ActiveXObject really does not exist. You will get an error like this,

Uncaught ReferenceError: ActiveXObject is not defined

  var network = new ActiveXObject('WScript.Network');
        // Show a pop up if it works
        alert(network.puterName);

本文标签: How to get computer name using javascript WScriptNetworkStack Overflow