Skip to content

Instantly share code, notes, and snippets.

@alvises
Created September 16, 2016 16:02
Show Gist options
  • Save alvises/0e57d9762f013b41b6116e03a2d1eef7 to your computer and use it in GitHub Desktop.
Save alvises/0e57d9762f013b41b6116e03a2d1eef7 to your computer and use it in GitHub Desktop.
<HTML>
<head>
<title>GeoIP test</title>
<script src="http://geoip.poeticoding.com/geoip.js" type="text/javascript"></script>
</head>
<body>
<div id="details">Loading...</div>
</body>
<script>
var geoip = new GeoIP();
geoip.locate(function(ip,location){
var details = document.getElementById("details")
var html = "<h1>IP: "+ip+"</h1>";
if(location)
html += "<h1>Location: "+location.country_name+", "+location.city_name+"</h1>";
details.innerHTML = html;
})
</script>
</HTML>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment