Skip to content

Instantly share code, notes, and snippets.

@robozevel
Created March 27, 2014 16:57
Show Gist options
  • Save robozevel/9812420 to your computer and use it in GitHub Desktop.
Save robozevel/9812420 to your computer and use it in GitHub Desktop.
Geolocate using Wikimedia's Geo IP Lookup service
var geolocate = function(callback) {
callback = typeof callback === "function" ? callback : function(){};
if ('Geo' in window) {
callback(window.Geo);
} else {
var script = document.createElement('script');
script.src = "https://geoiplookup.wikimedia.org/";
script.onload = function() { callback(window.Geo) };
document.head.appendChild(script);
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment