首页 | 联系我们 | 叶凡网络官方QQ群:323842844
游客,欢迎您! 请登录 免费注册 忘记密码
您所在的位置:首页 > 开发语言 > ASP开发 > 正文

asp手机打开自动跳转到移动站代码

作者:cocomyyz 来源: 日期:2015-07-02 22:15:50 人气:1 加入收藏 评论:0 标签:asp手机打开自动跳转到移动站代码
1.如果想手机访问pc站(如www.hfyefan.com)后自动跳转到手机站(www.hfyefan.com/wap 或者 m.hfyefan.com)的,
请在pc站首页(www.hfyefan.com下的index.asp文件)最上面加这个代码:

<%
HTTP_ACCEPT=Request.ServerVariables("HTTP_ACCEPT")                 '获取浏览器的信息
HTTP_USER_AGENT=LCase(Request.ServerVariables("HTTP_USER_AGENT"))  '获取AGENT
HTTP_X_WAP_PROFILE=Request.ServerVariables("HTTP_X_WAP_PROFILE")   'WAP特定信息 品牌机自带浏览器都会有
HTTP_UA_OS=Request.ServerVariables("HTTP_UA_OS")                   '手机系统,电脑为空
HTTP_VIA=LCase(Request.ServerVariables("HTTP_VIA"))                '网关信息
Dim WapStr
WAPstr=False
If ubound(split(HTTP_ACCEPT,"vnd.wap"))>0 Then WAPstr=True
If HTTP_USER_AGENT="" Then  WAPstr=True
If HTTP_X_WAP_PROFILE<>"" Then  WAPstr=True
If HTTP_UA_OS<>"" Then  WAPstr=True
IF ubound(split(HTTP_VIA,"wap"))>0 Then  WAPstr=True
IF ubound(split(HTTP_USER_AGENT,"netfront"))>0 Then  WAPstr=True
IF ubound(split(HTTP_USER_AGENT,"iphone"))>0 Then  WAPstr=True
IF ubound(split(HTTP_USER_AGENT,"opera mini"))>0 Then  WAPstr=True
IF ubound(split(HTTP_USER_AGENT,"ucweb"))>0 Then  WAPstr=True
IF ubound(split(HTTP_USER_AGENT,"windows ce"))>0 Then  WAPstr=True
IF ubound(split(HTTP_USER_AGENT,"symbianos"))>0 Then  WAPstr=True
IF ubound(split(HTTP_USER_AGENT,"java"))>0 Then  WAPstr=True
IF ubound(split(HTTP_USER_AGENT,"android"))>0 Then  WAPstr=True
If WAPstr=True Then    

response.redirect "http://m.hfyefan.com/5001"  '这里改成你的手机站地址(http://www.hfyefan.com/wap 或者 http://m.hfyefan.com)  
response.end

End if
%>


2.如果需要电脑访问手机站(www.hfyefan.com/wap 或者 m.hfyefan.com)自动跳转到电脑(pc)站的,
请在手机站首页(www.hfyefan.com/wap 或者 m.hfyefan.com 下的index.asp文件)最上面在这个代码下 

<%@LANGUAGE="VBscript" CODEPAGE="65001"%>

加这个代码:

<%
HTTP_ACCEPT=Request.ServerVariables("HTTP_ACCEPT")                 '获取浏览器的信息
HTTP_USER_AGENT=LCase(Request.ServerVariables("HTTP_USER_AGENT"))  '获取AGENT
HTTP_X_WAP_PROFILE=Request.ServerVariables("HTTP_X_WAP_PROFILE")   'WAP特定信息 品牌机自带浏览器都会有
HTTP_UA_OS=Request.ServerVariables("HTTP_UA_OS")                   '手机系统,电脑为空
HTTP_VIA=LCase(Request.ServerVariables("HTTP_VIA"))                '网关信息
Dim WapStr
WAPstr=False
If ubound(split(HTTP_ACCEPT,"vnd.wap"))>0 Then WAPstr=True
If HTTP_USER_AGENT="" Then  WAPstr=True
If HTTP_X_WAP_PROFILE<>"" Then  WAPstr=True
If HTTP_UA_OS<>"" Then  WAPstr=True
IF ubound(split(HTTP_VIA,"wap"))>0 Then  WAPstr=True
IF ubound(split(HTTP_USER_AGENT,"netfront"))>0 Then  WAPstr=True
IF ubound(split(HTTP_USER_AGENT,"iphone"))>0 Then  WAPstr=True
IF ubound(split(HTTP_USER_AGENT,"opera mini"))>0 Then  WAPstr=True
IF ubound(split(HTTP_USER_AGENT,"ucweb"))>0 Then  WAPstr=True
IF ubound(split(HTTP_USER_AGENT,"windows ce"))>0 Then  WAPstr=True
IF ubound(split(HTTP_USER_AGENT,"symbianos"))>0 Then  WAPstr=True
IF ubound(split(HTTP_USER_AGENT,"java"))>0 Then  WAPstr=True
IF ubound(split(HTTP_USER_AGENT,"android"))>0 Then  WAPstr=True
If WAPstr=False Then    

response.redirect "http://m.hfyefan.com"  '这里改成你的pc站地址(http://www.hfyefan.com)  
response.end

End if
%>


本文网址:http://www.mingyangnet.com/html/asp/2216.html
读完这篇文章后,您心情如何?
  • 0
  • 0
  • 0
  • 0
  • 0
  • 0
  • 0
  • 0
更多>>网友评论
发表评论
编辑推荐
  • 没有资料