请问用JS怎样使手机浏览网站自动跳转到WAP页面,同时手机上点击电脑版是返回WEB页面 30
就像DZ那种,听说是通过COOKIE实现的,COOKIE保存3小时什么的,请问怎样实现呢,我现在用的是这段代码,但是手机就点击电脑版也会自动跳转到WAPfunctionc...
就像DZ那种,听说是通过COOKIE实现的,COOKIE保存3小时什么的,请问怎样实现呢,我现在用的是这段代码,但是手机就点击电脑版也会自动跳转到WAP
function check_wap()
{
if (isset($_SERVER['HTTP_VIA'])) return true;
if (isset($_SERVER['HTTP_X_NOKIA_CONNECTION_MODE'])) return true;
if (isset($_SERVER['HTTP_X_UP_CALLING_LINE_ID'])) return true;
if (strpos(strtoupper($_SERVER['HTTP_ACCEPT']), "VND.WAP.WML") > 0) {
// Check whether the browser/gateway says it accepts WML.
$br = "WML";
} else {
$browser = isset($_SERVER['HTTP_USER_AGENT']) ? trim($_SERVER['HTTP_USER_AGENT']) : '';
if (empty($browser)) return true;
$clientkeywords = array(
'nokia', 'sony', 'ericsson', 'mot', 'samsung', 'htc', 'sgh', 'lg', 'sharp', 'sie-'
, 'philips', 'panasonic', 'alcatel', 'lenovo', 'iphone', 'ipod', 'blackberry', 'meizu',
'android', 'netfront', 'symbian', 'ucweb', 'windowsce', 'palm', 'operamini',
'operamobi', 'opera mobi', 'openwave', 'nexusone', 'cldc', 'midp', 'wap', 'mobile'
);
if (preg_match("/(" . implode('|', $clientkeywords) . ")/i", $browser) && strpos($browser, 'ipad') === false) {
$br = "WML";
} else {
$br = "HTML";
}
}
if ($br == "WML") {
return TRUE;
} else {
return FALSE;
}
}
if (check_wap()) {
if ($_GET['act'] == 'index') {
Header("Location:" . WAP_SITE_URL);
} elseif ($_GET['act'] == 'goods') {
$wapUrl = WAP_URL ;
Header("Location:" . $wapUrl);
}else{
//在没有适配更多控制器的时候只能统一跳转到wap的首页
Header("Location:" . WAP_URL);
}
exit();
} 展开
function check_wap()
{
if (isset($_SERVER['HTTP_VIA'])) return true;
if (isset($_SERVER['HTTP_X_NOKIA_CONNECTION_MODE'])) return true;
if (isset($_SERVER['HTTP_X_UP_CALLING_LINE_ID'])) return true;
if (strpos(strtoupper($_SERVER['HTTP_ACCEPT']), "VND.WAP.WML") > 0) {
// Check whether the browser/gateway says it accepts WML.
$br = "WML";
} else {
$browser = isset($_SERVER['HTTP_USER_AGENT']) ? trim($_SERVER['HTTP_USER_AGENT']) : '';
if (empty($browser)) return true;
$clientkeywords = array(
'nokia', 'sony', 'ericsson', 'mot', 'samsung', 'htc', 'sgh', 'lg', 'sharp', 'sie-'
, 'philips', 'panasonic', 'alcatel', 'lenovo', 'iphone', 'ipod', 'blackberry', 'meizu',
'android', 'netfront', 'symbian', 'ucweb', 'windowsce', 'palm', 'operamini',
'operamobi', 'opera mobi', 'openwave', 'nexusone', 'cldc', 'midp', 'wap', 'mobile'
);
if (preg_match("/(" . implode('|', $clientkeywords) . ")/i", $browser) && strpos($browser, 'ipad') === false) {
$br = "WML";
} else {
$br = "HTML";
}
}
if ($br == "WML") {
return TRUE;
} else {
return FALSE;
}
}
if (check_wap()) {
if ($_GET['act'] == 'index') {
Header("Location:" . WAP_SITE_URL);
} elseif ($_GET['act'] == 'goods') {
$wapUrl = WAP_URL ;
Header("Location:" . $wapUrl);
}else{
//在没有适配更多控制器的时候只能统一跳转到wap的首页
Header("Location:" . WAP_URL);
}
exit();
} 展开
2015-05-07
展开全部
n年前的代码了,现在都是智能手机了,没几个用wap的了,都是直接用html做手机版。百度:js判断ua
追问
我想问的是,判断跳转的同时用户手机浏览器点击电脑版的链接就访问电脑版,过3小时后cookie没了会自动跳转到WAP。可能是我没表达清楚,上面这段代码只是实现了自动跳转WAP版,但是在WAP上面点击电脑版链接它还是会自动跳转到WAP,而不是链接到电脑
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询