用js获取本地电脑信息(但是只能在IE浏览器下才行,其他浏览器其获取不到的):
代码如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>ieTest</title>
<script type="text/javascript">
window.onload = getusername;
function getusername(){
//js获取电脑信息
var WshNetwork = new ActiveXObject("WScript.Network");
var WshShell = new ActiveXObject ("WScript.Shell");
var $lDomain = document.getElementById('lDomain'),
$lcName = document.getElementById('lcName'),
$luName = document.getElementById('luName'),
$lDomainDn = document.getElementById('lDomainDn');
$lDomain.value =WshNetwork.UserDomain;
$lcName.value =WshNetwork.ComputerName;
$luName.value =WshNetwork.UserName;
$lDomainDn.value =WshShell.RegRead ("HKCU\\Volatile Environment\\USERDNSDOMAIN");
WshNetwork = null;
WshShell = null;
};
</script>
</head>
<body>
<input type='text' id='lDomain' value='' />
<input type='text' id='lcName' value='' />
<input type='text' id='luName' value='' />
<input type='text' id='lDomainDn' value='' />
</body>
</html>
ie
js
ie浏览器
电脑