MAC addresses in JavaScript

前端 未结 6 1951
抹茶落季
抹茶落季 2020-11-22 06:14

I know that we can get the MAC address of a user via IE (ActiveX objects).

Is there a way to obtain a user\'s MAC address using JavaScript?

6条回答
  •  情歌与酒
    2020-11-22 06:32

    i was looking for the same problem and stumbled upon the following code.

    How to get Client MAC address(Web):

    To get the client MAC address only way we can rely on JavaScript and Active X control of Microsoft.It is only work in IE if Active X enable for IE. As the ActiveXObject is not available with the Firefox, its not working with the firefox and is working fine in IE.

    This script is for IE only:

    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 = '';
        output = output + '';
        while (!e.atEnd()) {
            e.moveNext();
            var p = e.item();
            if (!p) continue;
            output = output + '';
            output = output + '';
            output = output + '';
            output = output + '';
        }
        output = output + '
    CaptionMACAddress
    ' + p.Caption; +'' + p.MACAddress + '
    '; document.getElementById("box").innerHTML = output; } showMacAddress();

提交回复
热议问题