展开全部
直接用JS更方便,更准确,
ASP
ifInStr(LCase(Request.ServerVariables("HTTP_ACCEPT")),"text/vnd.wap.wml")>0then
response.redirect"wap.asp"'如果是手机访问则跳转到32313133353236313431303231363533e59b9ee7ad9431333363353765wap.asp
response.end
else
response.redirect"default.asp"'如果电脑访问跳转到首页
response.end
endif
%>
JSfunctionuaredirect(f){
try{
if(document.getElementById("bdmark")!=null){
return
}
varb=false;
if(arguments[1]){
vare=window.location.host;
vara=window.location.href;
if(isSubdomain(arguments[1],e)==1){
f=f+"/#m/"+a;
b=true
}else{
if(isSubdomain(arguments[1],e)==2){
f=f+"/#m/"+a;
b=true
}else{
f=a;
b=false
}
}
}else{
b=true
}
if(b){
varc=window.location.hash;
if(!c.match("fromapp")){
if((navigator.userAgent.match(/(iPhone|iPod|Android|ios|SymbianOS)/i))){
location.replace(f)
}
}
}
}catch(d){}
}
functionisSubdomain(c,d){
this.getdomain=function(f){
vare=f.indexOf("://");
if(e>0){
varh=f.substr(e+3)
}else{
varh=f
}
varg=/^www\./;
if(g.test(h)){
h=h.substr(4)
}
returnh
};
if(c==d){
return1
}else{
varc=this.getdomain(c);
varb=this.getdomain(d);
if(c==b){
return1
}else{
c=c.replace(".","\\.");
vara=newRegExp("\\."+c+"$");
if(b.match(a)){
return2
}else{
return0
}
}
}
};
使用方法:
以上的JS是以前在百度抓下,现在不知道还是不是用这个,,你搜索一下JS判断PC手机,可以找到蛮多,有些更简单。。