GeoIP redirection
Posted: Thu Jun 26, 2014 7:32 am
Hello,
I am looking at doing location to page redirect so if you're from the UK you will get the number 123 and if you're from the US then you'll get 987 but I can't seem to get the hang of it.
Could someone please point me in the right direction? (The code I've got is below)
I am looking at doing location to page redirect so if you're from the UK you will get the number 123 and if you're from the US then you'll get 987 but I can't seem to get the hang of it.
Could someone please point me in the right direction? (The code I've got is below)
Code: Select all
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>removed</title>
<script type='text/javascript'>//<![CDATA[
window.onload=function(){
if(navigator.geolocation)
{
navigator.geolocation.getCurrentPosition(showPosition,showError);
}
else
{
alert("Geolocation is not supported by this browser.");
}
function showError(error)
{
switch(error.code)
{
case error.PERMISSION_DENIED:
alert("User denied the request for Geolocation.");
break;
case error.POSITION_UNAVAILABLE:
alert("Location information is unavailable.");
break;
case error.TIMEOUT:
alert("The request to get user location timed out.");
break;
case error.UNKNOWN_ERROR:
alert("An unknown error occurred.");
break;
}
}
function showPosition(pos)
{
if (pos.coords.longitude >= 55.378051 && pos.coords.longitude <= -3.435973 && pos.coords.latitude <= 37.090240 && pos.coords.latitude >= -95.712891)
{
alert("987");
//window.location = 'USD/';
}
else{
alert("123");
// window.location = 'GBP/';
}
}
}//]]>
</script>
</head>
<body>
</body>
</html>