JS獲取本地ip的方法

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>獲取IP地址</title>

<script src="http://pv.sohu.com/cityjson?ie=utf-8"></script>  

</head>
<body>
	<div style="width: 240px;height: 320px;border: 1px solid #ccc;border-radius: 5px;padding: 20px; margin: 200px auto;">
		地址:<input type="text" id="ip" name="ip"><br/>
		城市:<input type="text" id="cname" name="cname"><br/>
	</div>
	<script>
		//聲明
		var ip = returnCitySN["cip"];
		var cname = returnCitySN["cname"];
		//獲取
		document.getElementById("ip").value = ip;
		document.getElementById("cname").value = cname;
	</script>
</body>
</html>
相關文章
相關標籤/搜索