我正在使用symfony 1 当用户访问我的页面时:
http://cinqmondes-marseille.com
使用移动设备 我强制重定向到移动页面:
http://cinqmondes-marseille.com/smartphone/index.php
使用简单的脚本:
<?php
$detect = new Mobile_Detect;
$mobileRedirectOnce = $sf_user->getAttribute('mobileRedirectOnce');
if ($detect->isMobile() && $mobileRedirectOnce == null) {
$sf_user->setAttribute('mobileRedirectOnce', 1);
echo "window.location = 'http://cinqmondes-marseille.com/smartphone/index.php';";
}
?>
if ( navigator.userAgent.match(/Android/i) || navigator.userAgent.match(/BlackBerry/i) ||
navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/Palm/i) )
{
window.location = 'http://cinqmondes-marseille.com/smartphone/index.php';
}
</script>
当他点击:
VOIR NOTRE SITE
我想将他重定向到桌面版本页
http:/ /cinqmondes-marseille.com/
不再是移动页面
但我的脚本再次重定向到移动页面
因为它检测到移动设备
我该怎么做?
答案 0 :(得分:0)
这是你的javascript条件,除了检查移动设备之外它没有做任何其他检查。你已经在php中检查了移动设备,所以删除它,没有必要。