JS acquisition of Computer MAC address and IP implementation method _javascript skills

Source: Internet
Author: User

How to obtain computer MAC address and IP by JS

Copy Code code as follows:

These are the ActiveX Plug-ins in the system that are used to obtain IP and physical addresses.
<object id=locator classid=clsid:76a64158-cb41-11d1-8b02-00600806d9b6 viewastext> </OBJECT>
<object Id=foo classid=clsid:75718c9a-f029-11d1-a1ac-00c04fb6c223> </OBJECT>

<script language=jscript Event=onobjectready (objobject,objasynccontext) for=foo>
if (objobject.ipenabled!= null && objobject.ipenabled!= "undefined" && objobject.ipenabl ed = = True)
{
if (objobject.macaddress!= null && objobject.macaddress!= "undefined")
MACADDR = objobject.macaddress;
if (objobject.ipenabled && objobject.ipaddress (0)!= null && objobject.ipaddress (0)!= "und" Efined ")
ipaddr = objobject.ipaddress (0);
if (objobject.dnshostname!= null && objobject.dnshostname!= "undefined")
Sdnsname = Objobject.dnshostname;

}
</SCRIPT>
<script language=jscript>
var service = Locator. ConnectServer ();
var macaddr;
var ipaddr;
var domainaddr;
var sdnsname;
Service. Security_. impersonationlevel=3;
Service. Instancesofasync (foo, ' Win32_NetworkAdapterConfiguration ');

</SCRIPT> <script language=jscript event= "oncompleted (Hresult,perrorobject, Pasynccontext)" for= Foo>
Alert ("Physical Address" +macaddr+ "IP Address" +ipaddr+ "host name" +sdnsname))
</SCRIPT> "


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.