查看: 2665|回复: 1
收起左侧

[技巧] javascript可以获得mac地址

[复制链接]
skykitty
发表于 2009-9-11 00:25:10 | 显示全部楼层 |阅读模式
代码如下,应该是很简单的英文啦:

Advanced JavaScript with Internet Explorer: Retrieving Networking Configuration Information - How to retrieve MAC address and other extended network information using JavaScript

(Page 2 of 6 )

Now, let us try to extend the previous sample by showing further information about the network adapters.  The entire code for the sample is as follows:

<!DOCTYPE  HTML  PUBLIC  "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
      <head>
            <title></title>
            <meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
            <meta name="vs_targetSchema" content="http://schemas.
microsoft.com/intellisense/ie5">
            <script id="clientEventHandlersJS" language="javascript">
<!--

function Button1_onclick() {
      var locator = new ActiveXObject
"WbemScripting.SWbemLocator");
      var service = locator.ConnectServer(".");
      var properties = service.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration");
      var e = new Enumerator (properties);
      document.write("<table border=1>");
      dispHeading();
      for (;!e.atEnd();e.moveNext ())
      {
            var p = e.item ();
            document.write("<tr>");
            document.write("<td>" + p.Caption + "</td>");
            document.write("<td>" + p.IPFilterSecurityEnabled + "</td>");
            document.write("<td>" + p.IPPortSecurityEnabled + "</td>");
            document.write("<td>" + p.IPXAddress + "</td>");
            document.write("<td>" + p.IPXEnabled + "</td>");
            document.write("<td>" + p.IPXNetworkNumber + "</td>");
            document.write("<td>" + p.MACAddress + "</td>");
            document.write("<td>" + p.WINSPrimaryServer + "</td>");
            document.write("<td>" + p.WINSSecondaryServer + "</td>");
            document.write("</tr>");
      }
      document.write("</table>");
}

function dispHeading()
{
      document.write("<thead>");
      document.write("<td>Caption</td>");
      document.write("<td>IPFilterSecurityEnabled</td>");
        document.write("<td>IPPortSecurityEnabled</td>");
        document.write("<td>IPXAddress</td>");
      document.write("<td>IPXEnabled</td>");
      document.write("<td>IPXNetworkNumber</td>");
      document.write("<td>MACAddress</td>");
      document.write("<td>WINSPrimaryServer</td>");
      document.write("<td>WINSSecondaryServer</td>");
      document.write("</thead>");
}

//-->
            </script>
      </head>
      <body>
            <INPUT id="Button1" type="button" value="Button"
name="Button1" language="javascript" onclick="return Button1_onclick()">
      </body>
</html>

The explanation for the above code is very similar to that of the previous section. The only difference is that I added few more properties to get in-depth network configuration information.
烟丝
发表于 2009-9-11 00:54:35 | 显示全部楼层
测试过了,确实可以。[:26:]
您需要登录后才可以回帖 登录 | 快速注册

本版积分规则

手机版|杀毒软件|软件论坛| 卡饭论坛

Copyright © KaFan  KaFan.cn All Rights Reserved.

Powered by Discuz! X3.4( 沪ICP备2020031077号-2 ) GMT+8, 2025-1-26 07:46 , Processed in 0.125890 second(s), 16 queries .

卡饭网所发布的一切软件、样本、工具、文章等仅限用于学习和研究,不得将上述内容用于商业或者其他非法用途,否则产生的一切后果自负,本站信息来自网络,版权争议问题与本站无关,您必须在下载后的24小时之内从您的电脑中彻底删除上述信息,如有问题请通过邮件与我们联系。

快速回复 客服 返回顶部 返回列表