检测ip和地区
程序员文章站
2022-04-09 19:02:15
获取当前位置所在省份城市和所用网络IP ......
获取当前位置所在省份城市和所用网络ip
<!doctype html> <html> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width,initial-scale=1"> <title>检测ip和地区</title> </head> <body> <div class="box" style="text-align: center;"> <h1>您当前所在ip和地区</h1> <p id="city"></p> <p id="ip"></p> </div> <script src="https://cdn.bootcss.com/jquery/1.9.1/jquery.min.js"></script> <script type="text/javascript"> $(function(){ //获取城市ajax $.ajax({ url: 'http://api.map.baidu.com/location/ip?ak=ia6hffl660bvh43exmh9lri6', type: 'post', datatype: 'jsonp', success:function(data) { console.log(json.stringify(data)); $('#city').html(json.stringify(data.content.address_detail.province + "," + data.content.address_detail.city)) } }); //获取ip ajax $.ajax({ url: 'http://ip-api.com/json', success: function(data){ console.log(json.stringify(data)); $('#ip').html(json.stringify(data.query)) }, type: 'get', datatype: 'json' }); }) </script> </body> </html>
上一篇: SqlServer无备份下误删数据恢复
下一篇: python之字符串