<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Getting MAC Address From Javascript(IE Only)</title>
<script language="javascript">
function showMacAddress(){
var obj = new ActiveXObject("WbemScripting.SWbemLocator");
var s = obj.ConnectServer(".");
var properties = s.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration");
var e = new Enumerator (properties);
var output;
output='<table border="0" cellPadding="5px" cellSpacing="1px" bgColor="#CCCCCC">';
output=output + '<tr bgColor="#EAEAEA"><td>Caption</td><td>MACAddress</td></tr>';
while(!e.atEnd())
{
e.moveNext();
var p = e.item ();
if(!p) continue;
if(p.MACAddress){
output=output + '<tr bgColor="#FFFFFF">';
output=output + '<td>' + p.Caption; + '</td>';
output=output + '<td id="'+p.MACAddress+'">' + p.MACAddress + '</td>';
output=output + '</tr>';
}
}
output=output + '</table>';
document.getElementById("box").innerHTML=output;
}
</script>
</head>
<body>
<input type="button" value="Show MAC Address" onclick="showMacAddress()" />
<div id="box">
</div>
</body>
</html>
'Javascript Tip' 카테고리의 다른 글
해당날짜 요일 구하기 (0) | 2014.11.17 |
---|---|
[javascript] 숫자와 하이픈만 입력 (0) | 2014.10.15 |
[javascript] javascript 안에서 javascript 또 쓰기 (0) | 2013.06.21 |
[javascript] 한글/영문만 입력되는 스크립트 (0) | 2013.06.21 |
[javascript] 간단한 이미지 resize (0) | 2013.06.21 |