
正文
js获取当前城市名
提示:扫一扫查出行【扫一扫了解最新限行尾号】
复制提示
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
</head>
<body>
<div id="sina_ip_info"></div>
<script src="http://code.jquery.com/jquery-1.7.2.min.js" type="text/javascript"></script>
<script src="http://pv.sohu.com/cityjson?ie=utf-8"></script>
<script type="text/javascript">
var uip = returnCitySN["cip"].toString();
$.getScript('http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js&ip=' + uip, function (_result) {
var ipData = ""; //初始化保存内容变量
if (remote_ip_info.ret == '1') {
ipData += "IP 详细信息:<br>";
ipData += "IP:" + uip + "<br>";
ipData += "国家:" + remote_ip_info.country + "<br>";
ipData += "省份:" + remote_ip_info.province + "<br>";
ipData += "城市:" + remote_ip_info.city + "<br>";
ipData += "区:" + remote_ip_info.district + "<br>";
ipData += "ISP:" + remote_ip_info.isp + "<br>";
ipData += "类型:" + remote_ip_info.type + "<br>";
ipData += "其他:" + remote_ip_info.desc + "<br>";
$("#sina_ip_info").html(ipData); //显示处理后的数据
} else {
alert('错误', '没有找到匹配的 IP 地址信息!');
}
});
</script>
</body>
</html>







