Click here to Skip to main content
12,406,124 members (40,591 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: Javascript
Hi,
i want to display ip address and mac address of pc i have the following code but it does not working in my system please check this..
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Getting MAC Address From Javascript(IE Only)</title>
 
<script language="javascript">
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='<table border="0" cellpadding="5px" cellspacing="1px" bgcolor="#CCCCCC">';
	output=output + '<tr bgcolor="#EAEAEA"><td>Caption</td><td>MACAddress</td></tr>';
	while(!e.atEnd())
 
	{
		e.moveNext();
		var p = e.item ();
		if(!p) continue;
		output=output + '<tr bgcolor="#FFFFFF">';
		output=output + '<td>' + p.Caption; + '</td>';
		output=output + '<td>' + p.MACAddress + '</td>';
		output=output + '</tr>';
	}
 
	output=output + '</table>';
	document.getElementById("box").innerHTML=output;
}
</script>
 
</head>
<body>
	<input type="button" value="Show MAC Address" onclick="showMacAddress()" />
 
	<div id="box">
	</div>
</body>
</html>
Posted 1-Apr-13 21:02pm
Updated 1-Apr-13 21:06pm
v2
Comments
Style-7 2-Apr-13 4:58am
   
this may be disable by admin policy
this is not safe for user
Madhugundi 3-Apr-13 1:29am
   
means what

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web01 | 2.8.160726.1 | Last Updated 2 Apr 2013
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100