js获取mac地址(续)

<!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=gb2312"/>
<title>js获取mac地址</title>
<SCRIPT language="JavaScript">
function MacInfo(){
var locator =new ActiveXObject ("WbemScripting.SWbemLocator");
var service = locator.ConnectServer(".");
var properties = service.ExecQuery("Select * from Win32_NetworkAdapterConfiguration Where IPEnabled =True");
var e =new Enumerator (properties);
{
var p = e.item();
var mac = p.MACAddress;
alert(mac)
}
}
</SCRIPT>
<body>
<input type="button" onclick="MacInfo()"/>
</body>
</html>

这个代码可以直接运行的

只能在ie下使用
并有浏览器安全-->爱信任站点-->里添加你的站点,并把安全级别设置为低

net b/s版本的:http://www.cnblogs.com/0banana0/archive/2011/11/02/2233333.html

posted @ 2011-11-02 10:16  一个土豆一棵青菜  阅读(27692)  评论(0编辑  收藏  举报