用js获取电脑信息(是使用与IE浏览器)

用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' value='' />
<input type='text' value='' />
<input type='text' value='' />
<input type='text' value='' />
</body>
</html>

您可能感兴趣的文章:

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wddggg.html