asp下通过HTTP_USER_AGENT判断用户是从手机上访问,还是电脑IE上访问

2018-09-06 11:13

阅读:510

  通过HTTP_USER_AGENT判断用户是从手机上访问,还是电脑IE上访问。

asp代码片段:主要使用了正则匹配手机环境,大家可以补充手机平台。
复制代码 代码如下:
set regex = new regexp
regex.ignorecase = true
regex.global = true
regex.pattern = mini 9.5vx1000lge m800e860u940ux840compalwireless mobiahonglg380lgkulgu900lg210lg47lg920lg840lg370sam-rmg50s55g83t66vx400mk99d615d763el370sl900mp500samu3samu4vx10xda_samu5samu6samu7samu9a615b832m881s920n210s700c-810_h797mob-xsk16d848bmowsers580r800471xv120rim8c500foma:160xx160480xx640t503w839i250sprintw398samr810m5252c7100mt126x225s5330s820htil-g1fly v71s302-x113novarrak610i-three8325rc8352rcsanyovx54c888nx250n120mtk c5588s710t880c5005i;458xp404is210c5100telecas940c500s590fomasamsuvx8vx9a1000_mmsmyxa700gu1100bc831e300ems100me701me702m-threesd588s8008325rcac831mw200brew d88htc\/htc_touch355xm50km100d736p-9521telcosl74ktouchm4u\/me7028325rckddiphonelg sonyericssonsamsung240xx320vx10nokiasony cmdmotorolaup.browserup.linkmmpsymbiansmartphonemidpwapvodafoneo2pocketkindlemobilepsptreoiris3g_twindows ceopera mobiwindows ce; smartphone;windows ce; iemobileipodiphoneandroidopera miniblackberrypalm ospalmhiptopavantgofennecpluckerxiinoblazerelaineiris3g_twindows ceopera mobiwindows ce; smartphone;windows ce; iemobile

agent = request.ServerVariables(HTTP_USER_AGENT) &
if agent <> then
if not regex.test(agent) then
不是从手机来的访问,跳转到
response.redirect(
end if
end if

感谢老曹提供的asp代码。


评论


亲,登录后才可以留言!