手机访问网站域名时如果实现自动跳转到wap页面 ?
如何让用户输入wap手机网站的网址时自动跳转到wap网站 ?
wap页面自动跳转的实现方式 ?
如何判断访客是否是移动设备访问,自动跳转到wap页面 ?
手机自动跳转到手机页面,一个网址区分普通访问与手机访问 ?
本文就可以解决这些问题!
PHP检测代码:functionis_mobile(){
varregex_match=/(nokia|iphone|android|motorola|^mot-|softbank|foma|docomo|kddi|up.browser|up.link|htc|dopod|blazer|netfront|helio|hosin|huawei|novarra|CoolPad|webos|techfaith|palmsource|blackberry|alcatel|amoi|ktouch|nexian|samsung|^sam-|s[cg]h|^lge|ericsson|philips|sagem|wellcom|bunjalloo|maui|symbian|smartphone|midp|wap|phone|windowsce|iemobile|^spice|^bird|^zte-|longcos|pantech|gionee|^sie-|portalmmm|jigsbrowser|hiptop|^benq|haier|^lct|operas*mobi|opera*mini|320x320|240x320|176x220)/i;
varu=navigator.userAgent;
if(null==u){
returntrue;
}
varresult=regex_match.exec(u);
if(null==result){
returnfalse
}else{
returntrue
}
}
if(is_mobile()){
document.location.href='/wap';
}
ASP检测代码:HTTP_ACCEPT=Request.ServerVariables("HTTP_ACCEPT")'获取浏览器信息
HTTP_USER_AGENT=LCase(Request.ServerVariables("HTTP_USER_AGENT"))'获取AGENT
HTTP_X_WAP_PROFILE=Request.ServerVariables("HTTP_X_WAP_PROFILE")'WAP特定信息品牌机自带浏览器都会有
HTTP_UA_OS=Request.ServerVariables("HTTP_UA_OS")'手机系统电脑为空
HTTP_VIA=LCase(Request.ServerVariables("HTTP_VIA"))'网关信息
DimWapStr
WAPstr=False
Ifubound(split(HTTP_ACCEPT,"vnd.wap"))>0ThenWAPstr=True
IfHTTP_USER_AGENT=""ThenWAPstr=True
IfHTTP_X_WAP_PROFILE<>""ThenWAPstr=True
IfHTTP_UA_OS<>""ThenWAPstr=True
IFubound(split(HTTP_VIA,"wap"))>0ThenWAPstr=True
IFubound(split(HTTP_USER_AGENT,"netfront"))>0ThenWAPstr=True
IFubound(split(HTTP_USER_AGENT,"iphone"))>0ThenWAPstr=True
IFubound(split(HTTP_USER_AGENT,"operamini"))>0ThenWAPstr=True
IFubound(split(HTTP_USER_AGENT,"ucweb"))>0ThenWAPstr=True
IFubound(split(HTTP_USER_AGENT,"windowsce"))>0ThenWAPstr=True
IFubound(split(HTTP_USER_AGENT,"symbianos"))>0ThenWAPstr=True
IFubound(split(HTTP_USER_AGENT,"java"))>0ThenWAPstr=True
IFubound(split(HTTP_USER_AGENT,"android"))>0ThenWAPstr=True
IfWAPstr=TrueThen
'手机网址
response.redirect"/wap"
else
'电脑网址
response.redirect""
Endif
Js代码:
try{
varurlhash=window.location.hash;
if(!urlhash.match("fromapp"))
{
if((navigator.userAgent.match(/(iPhone|iPod|Android|ios|iPad)/i)))
{
window.location="/wap";
}
}
}
catch(err)
{
}
发表评论
您的IP:123.8.253.73,来自:河南省漯河市
1.0513info8
: 支持博主
/11/29 12:37:56
如果觉得《html自动跳转手机 手机浏览网站自动跳转到wap页面的代码》对你有帮助,请点赞、收藏,并留下你的观点哦!