JavaScript获取用户所在城市

<!doctype html>
<html lang="en">
 <head>
  <meta charset="UTF-8">
  <title>获取用户地理位置</title>
  <script type="text/javascript" src="./jquery-3.3.1.js"></script>
 </head>
 <body>
  
 </body>
</html>
<script>

$.getScript('http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js',function(){  
  alert(remote_ip_info.country);//国家  
  alert(remote_ip_info.province);//省份  
  alert(remote_ip_info.city);//城市  
});  

</script>

猜你喜欢

转载自blog.csdn.net/long_yi_1994/article/details/80026701