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
%>