Jump to content
Xander

GeoIP javascript api

Recommended Posts

Posted (edited)


<script language="JavaScript" src="http://j.maxmind.com/app/geoip.js"></script>

<br>Country Code:
<script language="JavaScript">document.write(geoip_country_code());</script>
<br>Country Name:
<script language="JavaScript">document.write(geoip_country_name());</script>
<br>City:
<script language="JavaScript">document.write(geoip_city());</script>
<br>Region:
<script language="JavaScript">document.write(geoip_region());</script>
<br>Region Name:
<script language="JavaScript">document.write(geoip_region_name());</script>
<br>Latitude:
<script language="JavaScript">document.write(geoip_latitude());</script>
<br>Longitude:
<script language="JavaScript">document.write(geoip_longitude());</script>
<br>Postal Code:
<script language="JavaScript">document.write(geoip_postal_code());</script>

sursa:

 http://www.maxmind.com/app/javascript_city 

Teoretic cica ar trebui sa pui link catre maxmind daca il folosesti pe site dar nu cred ca stau sa verifice...

EDIT:

uz posibil:



<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
$(function()
{
(
detect =
(
function()
{
if(typeof geoip_country_code != "function")
return setTimeout
(
function()
{
detect();
} , 10);
$.post("track.php" ,
{
"cc": geoip_country_code(),
"cn": geoip_country_name(),
"ct": geoip_city(),
"re": geoip_region(),
"rn": geoip_region_name(),
"lat": geoip_latitude(),
"long": geoip_longitude(),
"pc": geoip_postal_code()
});
}
)
)();
var _geoip = document.createElement("script");
_geoip.src = "//j.maxmind.com/app/geoip.js";
_geoip.async = true;
document.body.appendChild(_geoip);
});

avantaje: asincron si gratis...

Edited by Xander

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...