Hi this has doing my head in for an hour or so now, I want to redirect my mobile traffic but depending on the GEO to different locations, I have got the redirect script working fine using switch, case but when I add it within an if statement if (screen.width <= 699) for mobile devices its not working and I dont know why. this is what i have
<script language="JavaScript" src="http://j.maxmind.com/app/geoip.js"></script>
<script language="JavaScript">
var country = geoip_country_code();
if (screen.width <= 699) {
switch (country)
{
case (country = "ES"):
window.location = "http://url1.com";
break;
case (country = "US"):
window.location = "http://url1.com";
break;
default:
window.location = "http://url2.com";
break;
}
}
Just having it like this work fine…
<script language="JavaScript">
var country = geoip_country_code();
switch (country)
{
case (country = "ES"):
window.location = "http://url1.com";
break;
case (country = "US"):
window.location = "http://url1.com";
break;
default:
window.location = "http://url2.com";
break;
}
thanks in advance to anyone who can help me with this I really appreciate it!
Include the following in your html’s header:
So your mobile devices don’t resize to “desktop” emulation