浏览器移动端跳转适配

js 版

if(/Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)){ if(window.location.href.indexOf(“?mobile”)<0){try{window.location.href=”http://www.qq.com/mobile/index.htm”}catch(e){}} }

PHP版:

$ua = strtolower($_SERVER[‘HTTP_USER_AGENT’]);

$uachar = “/(nokia|sony|ericsson|mot|samsung|sgh|lg|philips|panasonic|alcatel|lenovo|cldc|midp|mobile)/i”;

if(($ua == ” || preg_match($uachar, $ua))&& !strpos(strtolower($_SERVER[‘REQUEST_URI’]),’wap’))
{
$Loaction = ‘mobile/’;

if (!empty($Loaction))
{
ecs_header(“Location: $Loactionn”);

exit;
}

}

 

来源: 腾讯:http;//www.qq.com和http://blog.sina.com.cn/s/blog_54318f230100u30w.html

留下评论

您的电子邮箱地址不会被公开。 必填项已用*标注