请教ASP检测手机客户端并跳转到相应页面,下面这段代码是找的,但是复制到页面里不好用,ASP我不是很懂。

[复制链接]
查看11 | 回复2 | 2011-11-1 09:53:12 | 显示全部楼层 |阅读模式
我要实现的是手机访问index.asp的跳转到wap.asp,同时wap.asp里有个“返回电脑版”的链接到index.asp这时候不进行跳转。下面是ZBLOG里的一段代码:%FunctionCheckMobile()\'是否由wap转入电脑版IfNotIsEmpty(Request.ServerVariables(\"HTTP_REFERER\"))AndInStr(LCase(Request.ServerVariables(\"HTTP_REFERER\")),ZC_FILENAME_WAP)ThenCheckMobile=False:ExitFunctionEndIf\'是否专用wap浏览器IfInStr(LCase(Request.ServerVariables(\"HTTP_ACCEPT\")),\"application/vnd.wap.xhtmlxml\")OrNotIsEmpty(Request.ServerVariables(\"HTTP_X_PROFILE\"))OrNotIsEmpty(Request.ServerVariables(\"HTTP_PROFILE\"))ThenCheckMobile=True:ExitFunctionEndIf\'是否(智能)手机浏览器DimMobileBrowser_List,PCBrowser_List,UserAgentMobileBrowser_List=\"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=\"mozilla|chrome|safari|opera|m3gate|winwap|openwave\"UserAgent=LCase(Request.ServerVariables(\"HTTP_USER_AGENT\"))IfCheckRegExp(UserAgent,MobileBrowser_List)ThenCheckMobile=True:ExitFunctionElseIfCheckRegExp(UserAgent,PCBrowser_List)Then\'未知手机浏览器,其UA标识为常见浏览器,不跳转CheckMobile=False:ExitFunctionElseCheckMobile=FalseEndIfEndFunctionIfCheckMobile()ThenResponse.Redirect(ZC_BLOG_HOST
回复

使用道具 举报

千问 | 2011-11-1 09:53:12 | 显示全部楼层
假如你的网址是:http://hi.baidu.com/aspxjsp/那你的Index.asp是http://hi.baidu.com/aspxjsp/index.asp那你的wap.asp是http://hi.baidu.com/aspxjsp/wap.asp那你的代码如下:%FunctionCheckMobile()\'是否由wap转入电脑版IfNotIsEmpty(Request.ServerVariables(\"HTTP_REFERER\"))AndInStr(LCase(Request.ServerVariables(\"HTTP_REFERER\")),\"wap.asp\")=0ThenCheckMobile=False:ExitFunctionEndIf\'是否专用wap浏览器IfInStr(LCase(Request.ServerVariables(\"HTTP_ACCEPT\")),\"application/vnd.wap.xhtmlxml\")OrNotIsEmpty(Request.ServerVariables(\"HTTP_X_PROFILE\"))OrNotIsEmpty(Request.ServerVariables(\"HTTP_PROFILE\"))ThenCheckMobile=True:ExitFunctionEndIf\'是否(智能)手机浏览器DimMobileBrowser_List,PCBrowser_List,UserAgentMobileBrowser_List=\"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=\"mozilla|chrome|safari|opera|m3gate|winwap|openwave\"UserAgent=LCase(Request.ServerVariables(\"HTTP_USER_AGENT\"))IfCheckRegExp(UserAgent,MobileBrowser_List)ThenCheckMobile=True:ExitFunctionElseIfCheckRegExp(UserAgent,PCBrowser_List)Then\'未知手机浏览器,其UA标识为常见浏览器,不跳转CheckMobile=False:ExitFunctionElseCheckMobile=FalseEndIfEndFunctionIfCheckMobile()ThenResponse.Redirect(“http://hi.baidu.com/aspxjsp/wap.asp\")%要想代码能用,你还需要CheckRegExp(UserAgent,MobileBrowser_List)这个函数的定义,就像上面的FunctionCheckMobile()一样。追问CheckRegExp(UserAgent,MobileBrowser_List)怎么定义呢,能给下代码吗,谢谢了,ASP不懂,只会简单点的。
回复

使用道具 举报

千问 | 2011-11-1 09:53:12 | 显示全部楼层
你的代码是从ZBLOG中来的那CheckRegExp(UserAgent,MobileBrowser_List)你就从ZBLOG中找,它的代码里有。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行