JS 利用新浪接口通过IP地址获取当前所在城市

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>通过IP获取当前所在城市</title>
<script src="js/jquery-1.8.1.js" type="text/javascript"></script>
<script src="http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js" type="text/ecmascript"></script>
<script type="text/javascript">
function getIpPlace() {
var province = remote_ip_info["province"];
var city = remote_ip_info["city"];

if(province=="北京" || province=="天津" || province=="上海" || province=="重庆"){
alert(province + "市" + city + "市");
}else{
alert(province + "省" + city + "市");
}

}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<input id="Button1" type="button" value="根据IP地址获取所在城市" onclick="getIpPlace();" />
</div>
</form>
</body>
</html>

posted @ 2013-11-01 15:51  积累从点滴开始  阅读(971)  评论(0编辑  收藏  举报