时间:2016-02-26 08:46 来源: 我爱IT技术网 作者:佚名
欢迎您访问我爱IT技术网,今天小编为你分享的电脑教程是站长建站系列之:【ASP判断用户是否为安卓/苹果手机客户端】,下面是详细的分享!
ASP判断用户是否为安卓/苹果手机客户端
通过JS判断的很常见吧,现在提供一个通过ASP判断用户是否为手机客户端。使用方法
if CheckMobile then '如果是手机浏览器那么就跳转到手机客户端
response.redirect “http://m.xiaoxiangzi.com”
response.end
end if
方法如下
Function CheckMobile()
if InStr(LCase(Request.ServerVariables("HTTP_ACCEPT")),"text/vnd.wap.wml")>0 then
CheckMobile=True: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
以上就是关于ASP判断用户是否为安卓/苹果手机客户端的手机问答知识分享,更多电脑教程请移步到>>电脑教程频道。
- 评论列表(网友评论仅供网友表达个人看法,并不表明本站同意其观点或证实其描述)
-
