JS获取IP经纬度,地址等


<html>
<head>
<title>xxxxx</title>
<meta http-equiv="content-type" content="text/html; charset=gb2312">
<script type="text/javascript" src="http://www.ip-look-up.com/Services/ipInfo.js"></script> 

</head>
<body onload=aa();>
<SCRIPT LANGUAGE="JavaScript">

function aa(){

	document.getElementById("lat").value = ipLocation.latitude;
	document.getElementById("long").value = ipLocation.longitude;
	document.getElementById("city").value = ipLocation.address.city;
	document.getElementById("long").value = ipLocation.longitude;
	document.getElementById("code").value = ipLocation.address.country_code;
	document.getElementById("region").value = ipLocation.address.region;
	document.getElementById("country").value = ipLocation.address.country;

}
</SCRIPT>

	经度:<input type="text" id="lat"><br/>
	纬度:<input type="text" id="long"><br/>
	城市:<input type="text" id="city"><br/>
	国家代码:<input type="text" id="code"><br/>
	城市所属地区:<input type="text" id="region"><br/>
	国家:<input type="text" id="country"><br/>
</body>
</html>



<script type="text/javascript" src="http://www.ip-look-up.com/Services/ipInfo.js?=0.0.0.0"></script> 

固定IP,调用方法和上面一样。

你可能感兴趣的:(input)