js获取 mac地址

2018-02-27 11:05:49来源:http://cuityang.iteye.com作者:cuityang人点击

分享
<html>
<head>
<title>JS get MAC</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta content="editplus" />
<script event="OnObjectReady(objObject,objAsyncContext)" for="foo">
if(objObject.IPEnabled!=null&&objObject.IPEnabled!="undefined"&&objObject.IPEnabled == true){
if(objObject.MACAddress!=null&&objObject.MACAddress!="undefined"&&objObject.DNSServerSearchOrder!=null)
MACAddr=objObject.MACAddress;
if(objObject.IPEnabled&&objObject.IPAddress(0)!=null&&objObject.IPAddress(0)!="undefined"&&objObject.DNSServerSearchOrder!=null)
IPAddr=objObject.IPAddress(0);
if(objObject.DNSHostName!=null&&objObject.DNSHostName!="undefined")
sDNSName=objObject.DNSHostName;
}
</script>
<script type="text/javascript">
var MACAddr;
var IPAddr;
var DomainAddr;
var sDNSName;
function init(){
var service=locator.ConnectServer();
service.Security_.ImpersonationLevel=3;
service.InstancesOfAsync(foo,'Win32_NetworkAdapterConfiguration');
}
function getMac(){
document.getElementById('txtMac').value=unescape(MACAddr);
}
</script>
</head>
<body onLoad="init()">
<object class VIEWASTEXT></object>
<object class></object>
<input type="text" />
<input type="button" value="Mac" onClick="getMac()" />
</body>
</html>

最新文章

123

最新摄影

闪念基因

微信扫一扫

第七城市微信公众平台