12月18th

asp一段代码让网站自动识别手机访问跳转至手机网站

DIY编程技术2426℃我来说两句!

只要把下面代码放到index.asp或者default.asp中,只要在首页代码顶部引用call Check_Wap(),这个也是我的工程中使用的代码。用正则判断方便简洁。

Sub Check_Wap() dim MoblieUrl,reExp,MbStr MoblieUrl="/3g/index.asp"''''手机网站路径 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 IfEnd Sub

本文出自:DIY博客园,链接:https://www.diybloghome.com/prology/1855.html,转载请注明!