Home >Web Front-end >JS Tutorial >Use Tencent's IP address library to locate IP physical address_javascript skills

Use Tencent's IP address library to locate IP physical address_javascript skills

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-05-16 18:22:371306browse

Call:

Copy code The code is as follows:




The displayed result is:
202.105.128.73 Shenzhen City, Guangdong Province
If no IP is required and only the region is required, the call is:
Copy code The code is as follows:



The displayed result is:
Shenzhen City, Guangdong Province
The above code also has a trick: UTF-8 page refers to the processing of JS file encoding with external encoding of GBK
http://fw.qq.com/ipaddress, and the js provided by this interface is GBK encoded. Since the page is UTF-8 encoded, the returned city name is used again on my page. The displayed code is garbled and cannot be quoted. Through the charset setting, the problem of garbled JavaScript files encoded as GBK is introduced in UTF-8 pages. And there is no need to write additional functions to process GBK to UTF-8 encoding. Similarly, if the JavaScript file referenced by the GBK page is encoded in UTF-8 encoding, there will be garbled problems.

Source: http://shanyou.cnblogs.com/
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