First, the use of JS to obtain the client IP several methods
Method one (only for IE and the client's IE allows Acitivex to run, through the platform: xp,server03,2000).
Get the client IP code:
<HTML>
<HEAD>
<TITLE>GetLocalIP</TITLE>
</HEAD>
<BODY>
Get IP:
<script language= "JavaScript" > Function getlocalipaddr () {var osetting = null; var IP = null; try{osetting = new Ac Tivexobject ("Rcbdyctl. Setting "); ip = osetting.getipaddress; if (Ip.length = = 0) {return "not connected to the Internet";} osetting = null; }catch (e) {return IP;} return IP; } document.write (Getlocalipaddr () + "<br/>") </script>
</BODY>
</HTML>
Method Two (all platforms and browsers):
Get the IP that the client is in the network, provided that the customer is networked. The Sina interface is used.
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">
<title>javascript get client ip[using Sina interface]_www.jbxue.com</title>
<body>
<script type= "Text/javascript" src= "http://counter.sina.com.cn/ip/" charset= "gb2312" ></script> <!-- Get interface data, note charset
<script type= "Text/javascript" >
Document.writeln ("IP address:" +ildata[0]+ "<br/>"); The IP address in the output interface data
Document.writeln ("Address type:" +ildata[1]+ "<br/>"); The type of IP address in the output interface data
Document.writeln ("Address type:" +ildata[2]+ "<br/>"); The provinces and municipalities of the IP addresses in the output interface data
Document.writeln ("Address type:" +ildata[3]+ "<br/>"); Of the IP address in the output interface data.
Document.writeln ("Address type:" +ildata[4]+ "<br/>"); The operator of the IP address in the output interface data
</script>
</body>
Method Three (all platforms and browsers):
Sohu Interface for use
<script src= "Http://pv.sohu.com/cityjson?ie=utf-8" ></script>
<script type= "Text/javascript" >
document.write (returncitysn["CIP"]+ ', ' +returncitysn["CNAME"])
</script>
Method four: Pacific Internet IP Query interface:
http://whois.pconline.com.cn/?ip=0.0.0.0
Replace the 0.0.0.0 with an IP address, and there are other extraneous content on the page that tells us which interfaces can be called, what interface calls parameters and how to use them, etc.
The above JS interface can be used to determine which city to use, directly display the relevant information of the city, for the need for city switching sites, the first to determine the user source is very helpful.
Second, use JS to get the computer name, MAC address, LAN IP (scripting Academy)
Method one (only for IE and the client's IE allows Acitivex to run):
Call the VBS script to get the computer name (some people do not know what the computer name is, the simple explanation is that it is the physical name of the machine instead of the user name you are using) and the login username.
<HTML>
<HEAD>
<TITLE>WMI Scripting html</title>
</HEAD>
<BODY>
<script language=javascript>
var WshShell =new ActiveXObject ("Wscript.Shell");
document.write ("Computer name =" + wshshell.expandenvironmentstrings ("%computername%") + "<br/>");
document.write ("Login username =" + wshshell.expandenvironmentstrings ("%USERNAME%") + "<br/>");
</script>
</BODY>
</HTML>
Method two (only for IE and the client's IE allows Acitivex to run):
Get the computer name, login username, and domain name (if you join a domain, it shows you which domain the machine is in).
<HTML>
<HEAD>
<TITLE>WMI Scripting html</title>
</HEAD>
<BODY>
<script language=javascript>
var wshnetwork = new ActiveXObject ("Wscript.Network");
document.write ("Domain name =" + wshnetwork.userdomain+ "<br/>");
document.write ("Computer name =" + wshnetwork.computername+ "<br/>");
document.write ("Login username =" + wshnetwork.username+ "<br/>");
</script>
</BODY>
</HTML>
Reference Link: JS three ways to get an IP address http://www.jbxue.com/article/11338.html
Method three (only for IE and the client's IE allows Acitivex to run):
Ability to get to LAN IP address, native Mac, and machine name (code source network).
<title></title>
<body>
<object classid= "Clsid:76a64158-cb41-11d1-8b02-00600806d9b6" id= "locator" style= "display:none;visibility: Hidden "></object>
<object classid= "clsid:75718c9a-f029-11d1-a1ac-00c04fb6c223" id= "foo" style= "Display:none;visibility:hidden" ></object>
<form name= "MyForm" >
<br/>mac Address: <input type= "text" name= "macAddress" >
<br/>ip Address: <input type= "text" name= "ipAddress" >
<br/> hostname: <input type= "text" name= "HostName" >
</form>
</body>
<script language= "JavaScript" >
var smacaddr= "";
var sipaddr= "";
var sdnsname= "";
var service = Locator. ConnectServer ();
Service. Security_. impersonationlevel=3;
Service. Instancesofasync (foo, ' Win32_NetworkAdapterConfiguration ');
</script>
<script for= "foo" event= "OnObjectReady (objobject,objasynccontext)" language= "JScript" >
if (objobject.ipenabled! = NULL && objobject.ipenabled! = "undefined" && objobject.ipenabled = = True) {
if (objobject.ipenabled && objobject.ipaddress (0)!=null && objobject.ipaddress (0)! = "undefined")
sipaddr = objobject.ipaddress (0);
if (objobject.macaddress! = null &&objobject.macaddress! = "undefined")
SMACADDR = objobject.macaddress;
if (objobject.dnshostname! = null &&objobject.dnshostname! = "undefined")
Sdnsname = Objobject.dnshostname;
}
</script>
<script for= "foo" event= "oncompleted (Hresult,perrorobject, Pasynccontext)" language= "JScript" >
MYFORM.MACADDRESS.VALUE=SMACADDR;
MYFORM.IPADDRESS.VALUE=SIPADDR;
Myform.hostname.value=sdnsname;
</script>
JS get client IP address, MAC and hostname seven ways