网站如何同时支持浏览器和wap浏览解决方法一例.txt

来自「c_c++技巧集」· 文本 代码 · 共 31 行

TXT
31
字号
作者:asp2001
email: asp2001@163.net
日期:2000-07-13 08:34:52
原理就是先判断http_user_agent的类型,如果是浏览器就response.redirect到
html文件,如果是wap就输出wml类型文件(好象不能用response.redirect到wml文件):
下面是我自己的一个例子,算是抛砖引玉,如果您有更高明的,不妨帖在下面。

default.asp

<%
useragent=request.serverVariables("http_user_agent")
if instr(useragent,"MSIE") or instr(useragent,"Netscape") then 
response.redirect "index.htm"
else
%>
<%Response.ContentType = "text/vnd.wap.wml; charset=UTF-8"%><?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">
<wml>
<head>
<meta http-equiv="Cache-Control" content="max-age=0"/>
</head>
<card id="greeting" ontimer="../wap/index.wml" title="welcome">
  <timer value="2"/>
  <p>
  welcome to......
  </p>
</card>
</wml>
<%
end if
%>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?