Created
March 27, 2014 16:57
-
-
Save robozevel/9812420 to your computer and use it in GitHub Desktop.
Geolocate using Wikimedia's Geo IP Lookup service
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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