Home > Article > Web Front-end > js implements PC-side positioning of current city location based on IP
Without further ado, please look at the code:
<script type="text/javascript"> $.getScript('http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js', function(_result) { if (remote_ip_info.ret == '1') { alert('国家:' + remote_ip_info.country +'\n省:' + remote_ip_info.province + '\n市:' + remote_ip_info.city + '\n区:' + remote_ip_info.district + '\nISP:' + remote_ip_info.isp + '\n类型:' + remote_ip_info.type + '\n其他:' + remote_ip_info.desc); } else { alert('没有找到匹配的IP地址信息!'); } }); </script>
The above is the entire content of this article. I hope that the content of this article can bring some help to everyone’s study or work. At the same time I also hope to support the PHP Chinese website!
For more js-based articles on PC-side positioning of current city location based on IP, please pay attention to the PHP Chinese website!