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>

 

转载于:https://www.cnblogs.com/wlzhang/p/4937044.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值