ASP网站识别手机访问 首页内页实现自动跳转
很多ASP网站站长都知道,ASP网站自带了手机访问首页实现自动跳转移动手机站首页的功能,可是没有手机移动端访问内页时,自动跳转到对应的手机移动端内页的功能。经过研究,电商博客就自己的方法分享给大家,轻松实现ASP网站识别手机移动端访问, 首页和内页分别实现自动跳转到对应手机移动端页面的功能。
ASP网站首页识别手机访问实现自动跳转
Sub Check_Wap() dim MoblieUrl,reExp,MbStr MoblieUrl="http://m.cqfoxconnjob.com"'此为手机网站路径,各位在复制代码时只要将此路径修改成指定手机网站的路径即可。推荐使用独立手机网站域名。 Set reExp = New RegExp MbStr="Android|iPhone|UC|Windows Phone|webOS|BlackBerry|iPod" reExp.pattern=".*("&MbStr&").*" reExp.IgnoreCase = True reExp.Global = True If reExp.test(Request.ServerVariables("HTTP_USER_AGENT")) Then response.redirect MoblieUrl response.End End If End Sub
ASP网站内页识别手机访问实现自动跳转
Sub PageCheck_Wap() dim MoblieUrl,reExp,MbStr MoblieUrl="http://m.cqfoxconnjob.com"&GetLocationURL Set reExp = New RegExp MbStr="Android|iPhone|UC|Windows Phone|webOS|BlackBerry|iPod" reExp.pattern=".*("&MbStr&").*" reExp.IgnoreCase = True reExp.Global = True If reExp.test(Request.ServerVariables("HTTP_USER_AGENT")) Then response.redirect MoblieUrl response.End End If End Sub Function GetLocationURL() Dim Url Dim ServerPort,ServerName,ScriptName,QueryString ServerName = Request.ServerVariables("SERVER_NAME") ServerPort = Request.ServerVariables("SERVER_PORT") ScriptName = Request.ServerVariables("SCRIPT_NAME") QueryString = Request.ServerVariables("QUERY_STRING") Url=ServerName If ServerPort <> "80" Then Url = Url & ":" & ServerPort Url=ScriptName If QueryString <>"" Then Url=Url&"?"& QueryString GetLocationURL=Url End Function
themebetter
方法不错。