Created
March 25, 2015 08:57
-
-
Save mchericoni/638e813c7b7a244b36e2 to your computer and use it in GitHub Desktop.
Geolocation and redirect depending on Country
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Geolocation</title> | |
<meta charset="utf-8"> | |
<script | |
src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script> | |
<script> | |
$(document).ready(function() { | |
$.get("http://ipinfo.io", function(response) { | |
console.log(response.ip, response.country); | |
if (response.country == 'GB') { | |
window.location.replace("http://www.google.co.uk"); | |
} | |
}, "jsonp"); | |
}); | |
</script> | |
</head> | |
Sample content | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment