Skip to content

Instantly share code, notes, and snippets.

@mchericoni
Created March 25, 2015 08:57
Show Gist options
  • Save mchericoni/638e813c7b7a244b36e2 to your computer and use it in GitHub Desktop.
Save mchericoni/638e813c7b7a244b36e2 to your computer and use it in GitHub Desktop.
Geolocation and redirect depending on Country
<!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