Home  >  Article  >  Web Front-end  >  js implements PC-side positioning of current city location based on IP

js implements PC-side positioning of current city location based on IP

高洛峰
高洛峰Original
2017-02-23 17:31:383020browse

Without further ado, please look at the code:

<script type="text/javascript">
 $.getScript(&#39;http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js&#39;, function(_result) {
 if (remote_ip_info.ret == &#39;1&#39;) {
 alert(&#39;国家:&#39; + remote_ip_info.country +&#39;\n省:&#39; + remote_ip_info.province + &#39;\n市:&#39; + remote_ip_info.city + &#39;\n区:&#39; + remote_ip_info.district + &#39;\nISP:&#39; + remote_ip_info.isp + &#39;\n类型:&#39; + remote_ip_info.type + &#39;\n其他:&#39; + remote_ip_info.desc);
 } else {
 alert(&#39;没有找到匹配的IP地址信息!&#39;);
 }
 });
</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!


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn