h5获取当前浏览器ip和城市名称

直接4行代码搞定

    <script src="http://pv.sohu.com/cityjson?ie=utf-8"></script>
    <script type="text/javascript">
        document.write(returnCitySN["cip"]+','+returnCitySN["cname"])
    </script>

搜狐IP地址查询接口(默认GBK):http://pv.sohu.com/cityjson
搜狐IP地址查询接口(可设置编码):http://pv.sohu.com/cityjson?ie=utf-8
搜狐另外的IP地址查询接口:http://txt.go.sohu.com/ip/soip

猜你喜欢

转载自blog.csdn.net/fu415037685/article/details/80985775