[英]Javascript mobile redirect issue
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. 嗨,这已经花了我一个小时左右的时间,我想重定向移动流量,但是根据GEO到不同的位置,我已经使用switch,case来使重定向脚本正常工作,但是当我在if中添加它时声明是否(screen.width <= 699)对于移动设备不起作用,我不知道为什么。 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: 在html标头中包含以下内容:
<meta name="viewport" content="width=device-width, user-scalable=no" />
So your mobile devices don't resize to "desktop" emulation 因此,您的移动设备不会调整为“桌面”仿真的大小
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.