First introduce the JavaScript API File
<Script type = "text/javascript" src = "http://j.maxmind.com/app/geoip.js"> </script>
This API provides six interfaces, geoip_country_code () {Country Code}, geoip_country _ name () {country name}, geoip_city () {city name}, geoip_region () {region code}, geoip_latitude () {longitude}, geoip_longdistance () {latitude }.
The region code is a kind of code used internally by MaxMind. The province-level administrative regions of each country are numbered in audio order. Some methods can be used to convert the code to the Administrative Region name.
Instance used:
Copy codeThe Code is as follows:
<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>