複製代碼代碼如下:
<html>
<頭>
<title> </title>
</head>
<身體>
<object classID =“ clSID:76A64158-CB41-11D1-8B02-00600806D9B6”
<object classID =“ clSID:75718C9A-F029-11D1-A1AC-00C04FB6C223”
<form name =“ myform”>
<br/> mac地址:<input type =“ text” name =“ macaddress”>
<br/> ip地址:<input type =“ text” name =“ ipaddress”>
<br/>主機名:<input type =“ text” name =“ hostName”>
</form>
</body>
</html>
<腳本語言=“ javascript”>
var smacaddr =“”;
var sipaddr =“”;
var sdnsname =“”;
var service = locator.connectServer();
service.security_.ImpersonationLevel = 3;
service.instancesofAsync(foo,'win32_networkAdapterConfiguration');
</script>
<=“ foo” event =“ onobjectReady(objobject,objasyncconcontext)” language =“ jscript”>
if(objobject.ipenabled!= null && objobject.ipenabled!=“ undefined” && objobject.ipenabled == true){
if(objobject.ipenabled && objobject.ipaddress(0)!= null && objobject.ipaddress(0)!=“ undefined” && objobject.dnsserversearcherearch offeressearch!= null)
sipaddr = objobject.ipaddress(0);
if(objobject.macaddress!= null && objobject.macaddress!=“ undefined”)
smacaddr = objobject.macaddress;
如果(objobject.dnshostname!= null && objobject.dnshostname!=“ undefined”)
sdnsname = objobject.dnshostname;
}
</script>
<script for =“ foo” event =“ oncompleted(hresult,perrorobject,pasyncconcontext)”語言=“ jscript”>
myform.macaddress.value = smacaddr;
myform.ipaddress.value = sipaddr;
myform.hostname.value = sdnsname;
</script>
代碼是網上找到,但是經過修改。,但是經過修改。
原因是比如你筆記本有多張網卡
objobject.dnsserversearchorder!= null
加上這個限制條件後,就能取到聯網客戶端的網卡,IP地址了。
不過還有個問題就是只能限制ie瀏覽器,而且activex必須要全部啟用。