asp判断手机访问
❶ asp中如何判断电脑还是手机访问
quest.ServerVariables("HTTP_ACCEPT")),"text/vnd.wap.wml")>0 then
response.redirect "" '如果是手机访问则跳转WAP页面
response.end
else
response.redirect "" '如果电脑访问跳转到首页
response.end
end if
%>
❷ asp判断用户端是电脑访问还是移动设备方法
直接用JS更方便,更准确,
ASP
<%
ifInStr(LCase(Request.ServerVariables("HTTP_ACCEPT")),"text/vnd.wap.wml")>0then
response.redirect"wap.asp"'如果是手机访问则跳转到wap.asp
response.end
else
response.redirect"default.asp"'如果电脑访问跳转到首页
response.end
endif
%>
JS
functionuaredirect(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
}
}
}
};
使用方法:
<SCRIPTtype=text/javascript>uaredirect("手机站","WEB站");</SCRIPT>
以上的JS是以前在网络抓下,现在不知道还是不是用这个,,你搜索一下JS判断PC手机,可以找到蛮多,有些更简单。。
❸ 我的网站是asp,加什么代码可以让网站自动识别手机访问跳转至手机网站
<%
if
InStr(LCase(Request.ServerVariables("HTTP_ACCEPT")),"vnd.wap.wml")>0
then
response.redirect
"a.asp"
'如果是手机访问则跳转a.asp,a.asp可以设置为你的手机网站主页
response.end
end
if%>
以上这段代码,加在你首页的头部就可以了,如果你想要全站都跳转的话,可以回你整站配置的config.asp文件里
❹ asp.net 判断是否是手机访问
这个只能通过客户端传递的User-agent来判断
比如正常pc是:Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; SV1;)
常用手机的UserAgent你可以去网上找找,或者自己连手机测试,
比如Nokia5320的是:Nokia 5320/UCWEB7.0.1.34/28/999
HTC的安卓手机:Mozilla/5.0 (Linux; U; Android 2.2; zh-cn; HTC Desire Build/FRF91) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1;
iPhone的:Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_1_2 like Mac OS X; zh-cn) AppleWebKit/528.18 (KHTML, like Gecko) Mobile/7D11
❺ asp如何判断是手机访问还是电脑访问
<% if InStr(LCase(Request.ServerVariables("HTTP_ACCEPT")),"text/vnd.wap.wml")>0 then response.redirect "wap.asp" '如果是手机访问则跳转到wap.asp response.end else response.redirect "default.asp" '如果电脑访问跳转到首页 response.end end if %>
❻ 网站是asp,加什么代码可以让网站自动识别手机访问跳转至手机网站
只要把下面代码放到index.asp或者default.asp中,只要在首页代码顶部引用call Check_Wap(),这个也是我的工程中使用的代码。用正则判断方便简洁。
Sub Check_Wap()
dim MoblieUrl,reExp,MbStr
MoblieUrl="/3g/index.asp"''手机网站路径
Set reExp = New RegExp
MbStr="Android|iPhone|UC|Windows Phone|webOS|BlackBerry|iPod"
reExp.pattern=".*("&MbStr&").*"
reExp.IgnoreCase = True
reExp.Global = True
If reExp.test(Request.ServerVariables("HTTP_USER_AGENT")) Then
response.redirect MoblieUrl
response.End
End If
End Sub
❼ asp中怎样实现判断是手机访问还是电脑浏览器访问
如果是手机访问则跳转到wap.asp,如果电脑访问跳转到response.end。
❽ asp判断是手机访问还是电脑访问
<%
if InStr(LCase(Request.ServerVariables("HTTP_ACCEPT")),"text/vnd.wap.wml")>0 then
response.redirect "wap.asp" '如果是手机访问则跳转到wap.asp
response.end
else
response.redirect "default.asp" '如果电脑访问跳转到首页
response.end
end if
%>