利用腾讯的ip地址库做ip物理地址定位_javascript技巧

WBOY
Release: 2016-05-16 18:22:37
Original
1142 people have browsed it

调用:

复制代码代码如下:




显示结果为:
202.105.128.73 广东省 深圳市
不要ip只要地区的话调用为:
复制代码代码如下:




显示结果为:
广东省 深圳市
上述代码还有一个技巧:UTF-8页面引用外部编码为GBK的JS文件编码的处理
http://fw.qq.com/ipaddress,而这个接口提供的js为GBK编码的,由于页面是UTF-8编码的,所以再次使用返回的城市名称在我页面显示的是乱码,而且不能引用的。通过charset设置,在UTF-8页面中引入编码为GBK的JavaScript文件乱码问题了。而且不需要额外的写函数处理GBK转UTF-8编码,同样对于GBK页面引用编码为UTF-8编码的JavaScript文件如果出现乱码问题。

出处:http://shanyou.cnblogs.com/
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
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!