Home > Web Front-end > JS Tutorial > body text

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

高洛峰
Release: 2017-02-23 17:31:38
Original
3019 people have browsed it

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>
Copy after login

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!


Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!