Getting Client Machine Mac address using Javascript

<!– This Script only works in IE browser –>

<script id=”clientEventHandlersJS” language=”javascript” type=”text/javascript”>
<!–
function clientMac() {
var locator = new ActiveXObject(“WbemScripting.SWbemLocator”);
var service = locator.ConnectServer(“.”);
var properties = service.ExecQuery(“SELECT * FROM Win32_NetworkAdapterConfiguration”);
var e = new Enumerator (properties);

for (;!e.atEnd();e.moveNext ())
{
var p = e.item ();

var mystring= new String(p.Caption);
var myregExp=’PCI’;
var answerIdx=mystring.search(myregExp)
if(answerIdx != -1 && p.MACAddress != null)
{
document.write(p.MACAddress);
}
else
{
var mystring= new String(p.Caption);
var myregExp=’NIC’;
var answerIdx=mystring.search(myregExp)
if(answerIdx != -1 && p.MACAddress != null)
{
document.write(p.MACAddress);
}
}

}
}
clientMac();
//–>
</script>

One Response to Getting Client Machine Mac address using Javascript

  1. did you try this in Mozilla Firefox or Opera?
    I think these codes is not working well in any other browser, only for IE.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: