• 获取本地客户端ip 局域网ip 物理地址mac 主机名


    此方法适用于IE浏览器.无需联网即可查询.

    <html>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <head>
    
    <title></title>
    
    </head>
    
    <body>
    
    <object classid="CLSID:76A64158-CB41-11D1-8B02-00600806D9B6" id="locator" style="display:none;visibility:hidden"></object>
    
    <object classid="CLSID:75718C9A-F029-11d1-A1AC-00C04FB6C223" id="foo" style="display:none;visibility:hidden"></object>
    
    <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>
    
    <script language="javascript">
    
    var sIPAddr="";
    
    var sDNSName="";
    
    var service = locator.ConnectServer();
    
    service.Security_.ImpersonationLevel=3;
    
    service.InstancesOfAsync(foo, 'Win32_NetworkAdapterConfiguration');
    
    </script>
    
    <script FOR="foo" EVENT="OnObjectReady(objObject,objAsyncContext)" LANGUAGE="JScript">
    
             if(objObject.IPEnabled != null && objObject.IPEnabled != "undefined" && objObject.IPEnabled == true){
    
                               if(objObject.IPEnabled && objObject.IPAddress(0) !=null && objObject.IPAddress(0) != "undefined")
    
                                             sIPAddr = objObject.IPAddress(0);
    
                               if(objObject.MACAddress != null &&objObject.MACAddress != "undefined")
    
                         sMacAddr = objObject.MACAddress;
    
                               if(objObject.DNSHostName != null &&objObject.DNSHostName != "undefined")
    
                                             sDNSName = objObject.DNSHostName;
                                             console.log(sIPAddr);
    
              }
    
    </script>
    
    <script FOR="foo" EVENT="OnCompleted(hResult,pErrorObject, pAsyncContext)" LANGUAGE="JScript">
    
    myForm.macAddress.value=sMacAddr;
    
    myForm.ipAddress.value=sIPAddr;
    
    myForm.hostName.value=sDNSName;
    
    </script>

    网页效果:允许控件执行.(此窗口在项目中运行,可以在ie Internet选项-安全-受信任站点-站点-添加 进行设置,以及自定义级别内的ActiveX的相关设置,设置之后就不再弹出提示框);

    ip地址可能有多个:如局域网网的ip,无线网卡的ip等.可在控制台刷新页面查看所有的ip地址.

  • 相关阅读:
    递归部门
    web攻击几种方法
    β版本apk下载地址及源代码github地址
    软件工程第六组U-Helpβ版使用说明
    软件工程第六组(六扇门)β版本最终答辩博客
    alpha版本展示
    用户Bug修补报告
    任务墙最终版
    个人总结-尹童欣
    个人总结-齐天浩
  • 原文地址:https://www.cnblogs.com/s-xl/p/7983459.html
Copyright © 2020-2023  润新知