【ASP】判断是否是手机访问

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

if CheckMobile then
Response.redirect "mobile.asp" 
end if%>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值