


Detailed code explanation for using the API (JavaScript interface) provided by Google to obtain the IP geographical location of website visitors_javascript skills
May 16, 2016 pm 06:22 PMFirst introduce the JavaScript API file
<script type="text/javascript" src="http://j.maxmind.com/app/geoip.js"></script>
This API provides a total of 6 interfaces, geoip_country_code(){country code}, geoip_country_ name(){country name}, geoip_city() {city name}, geoip_region(){region code}, geoip_latitude(){longitude },geoip_longitude(){latitude}.
The region code is a code used internally by MaxMind. The numbers given by the provincial administrative regions in various countries in phonetic order can be converted into administrative region names through certain methods.
Usage example:
<html> ;
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>JavaScript API</ title>
<script type="text/javascript" src="http://j.maxmind.com/app/geoip.js"></script>
</head>
<body>
<script type="text/javascript">
var area = "";
try
{
if(geoip_city() != "" && geoip_city() != null)
area = geoip_city() ", ";
if(geoip_region_name() != "" && geoip_region_name() != null)
area = geoip_region_name() ", ";
if(geoip_country_name() != "" && geoip_country_name() != null)
area = geoip_country_name();
}
catch(err)
{
area ="";
}
</script>
</body>
</html>

Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Google Pixel 9 and Pixel 9 Pro rumoured to gain Creative Assistant AI upon release

Google Tensor G4 of Pixel 9 Pro XL lags behind Tensor G2 in Genshin Impact

Google app beta APK teardown reveals new extensions coming to Gemini AI assistant

Google AI announces Gemini 1.5 Pro and Gemma 2 for developers

Google Pixel 9 smartphones will not launch with Android 15 despite seven-year update commitment

New Google Pixel desktop mode showcased in fresh video as possible Motorola Ready For and Samsung DeX alternative

Google Pixel 9 Pro XL gets tested with desktop mode

Google opens AI Test Kitchen & Imagen 3 to most users
