最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - obtain mac address from browser including chrome, windows, safari, firefox - Stack Overflow

programmeradmin1浏览0评论

Could browser inside a machine obtain the machine's MAC address? I'm building an API which need obtain unique identification of the machine (ideally, it could be MAC address), however, after discussion and research, I realize browsers don't support this. If not, any way the browser could obtain device related data which could be used to replace MAC address?

Could browser inside a machine obtain the machine's MAC address? I'm building an API which need obtain unique identification of the machine (ideally, it could be MAC address), however, after discussion and research, I realize browsers don't support this. If not, any way the browser could obtain device related data which could be used to replace MAC address?

Share Improve this question asked Jul 14, 2016 at 21:04 sean ansean an 1351 gold badge3 silver badges12 bronze badges 5
  • You can not get that info from JavaScript. There is no way to identify anyone directly and whatever you try can also be changed. Why do you need to know the machine? Maybe there is a different solution. – epascarello Commented Jul 14, 2016 at 21:11
  • trying to restrict the machine can use the app – sean an Commented Jul 14, 2016 at 21:16
  • 1 So you will either need to install some sort of plugin that has to get around security to get the mac address (even plugins have no access) or you need to rethink it and make it so users need to log in, or maybe think of a native app instead of a web app. – epascarello Commented Jul 14, 2016 at 21:20
  • native app has no problem. user can login from any device. but i want to restrict them only using certain device. – sean an Commented Jul 14, 2016 at 21:22
  • 1 Possible duplicate of How do I uniquely identify puters visiting my web site? – Lionia Vasilev Commented Jan 26, 2017 at 9:52
Add a ment  | 

2 Answers 2

Reset to default 1

The Answer is no, a browser can't access the MAC address of a Device, with regular Js. However, have you explored Node JS? It has a Mac Plugin that perhaps could be used in conjunction with another plugin called Browserify, Which could get you what you wanted. The benefit of using node is the massive amount of plugins that allow you to do things with js in your browser that you can't otherwise.

But you could create a unique UID on the page load, and save it somehow through localstorage, and pull that when you need a Device Specific ID. This won't work cross browser though. Hope this points you in the right direction. Good Luck.

For IE and ActiveX allowed:

function networkInfo(){

var wmi = new ActiveXObject ("WbemScripting.SWbemLocator");
var service = wmi.ConnectServer(".");


e = new Enumerator(service.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True"));


for(; !e.atEnd(); e.moveNext()) {
    var s = e.item();
    var macAddress = unescape(s.MACAddress);

}

return macAddress;
}
alert(networkInfo());

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论