<%
Function CheckMobile()
'是否由wap转入电脑版
If Not IsEmpty(Request.ServerVariables("HTTP_REFERER")) And InStr(LCase(Request.ServerVariables("HTTP_REFERER")),"wap/index.asp")=0 Then
CheckMobile=False:Exit Function
End If
'是否专用wap浏览器
If InStr(LCase(Request.ServerVariables("HTTP_ACCEPT")), "application/vnd.wap.xhtml+xml") Or Not IsEmpty(Request.ServerVariables("HTTP_X_PROFILE")) Or Not IsEmpty(Request.ServerVariables("HTTP_PROFILE")) Then
CheckMobile=True:Exit Function
End If
'是否(智能)手机浏览器
Dim MobileBrowser_List,PCBrowser_List,UserAgent
Set MobileBrowser_List = New RegExp '建立正则表达式
Set PCBrowser_List = New RegExp '建立正则表达式
MobileBrowser_List.Pattern ="up.browser|up.link|mmp|iphone|android|wap|netfront|java|opera\smini|ucweb|windows\sce|symbian|series|webos|sonyericsson|sony|blackberry|cellphone|dopod|nokia|samsung|palmsource|palmos|pda|xphone|xda|smartphone|pieplus|meizu|midp|cldc|brew|tear"
PCBrowser_List.Pattern="mozilla|chrome|safari|opera|m3gate|winwap|openwave"
UserAgent = LCase(Request.ServerVariables("HTTP_USER_AGENT"))
If MobileBrowser_List.Test(UserAgent) Then
CheckMobile=True:Exit Function
ElseIf PCBrowser_List.Test(UserAgent) Then '未知手机浏览器,其UA标识为常见浏览器,不跳转
CheckMobile=False:Exit Function
Else
CheckMobile=False
End If
End Function
If CheckMobile() Then
Response.Redirect ("wap/index.asp")
end if
%>
<%
if InStr(LCase(Request.ServerVariables("HTTP_ACCEPT")),"text/vnd.wap.wml")>0 then
response.redirect("wap/index.asp") '如果是手机访问则跳转WAP页面
else
response.redirect("index.html")
end if
%>
【详细说明
跳转http://zhidao.baidu.com/question/329884999.html
正则表达式http://www.jb51.net/article/20816.htm
】
该博客介绍了如何使用ASP技术检测访问者是否来自手机客户端,并根据检测结果自动跳转到相应的WAP页面,提供了详细的步骤和正则表达式参考链接。
1790

被折叠的 条评论
为什么被折叠?



