Welcome aboard! We are happy you are here and wish you good net-raft!
// this is the complete code for javascript framework Node.js
// you can get domainName and computerName
// at first you install "npm install --save path"
var http = require('http');
var path = require('path');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/html'});
var userName = process.env['USERPROFILE'].split(path.sep)[2];
var computerName = process.env['COMPUTERNAME'];
var loginId1 = path.join("domainName",userName);
var loginId2 = path.join("computerName",computerName);
res.write(loginId1 + '<br>');
res.write(loginId2 + '<br>');
res.end();
}).listen(3000);
console.log("Listening to Port 3000");
// works only for IE in intranet or local machine, there is a security reason
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<script type="text/javascript">
$(document).ready(function () {
try
{
var ax = new ActiveXObject("WScript.Network");
alert('User: ' + ax.UserName );
alert('Computer: ' + ax.ComputerName);
}
catch (e)
{
alert('Permission to access computer name is denied');
}
});
</script>
</body>
</html>
The most helpful JQUERY solutions
plugin get client ip address using jqueryJQUERY Click to see more ... 10.8K 1.8K