Wap中常见Asp+Wml问题

Wap中常见Asp+Wml问题

在HTML中有一个默认的E-Mail机制:" mailto:" 。但在WML中不好使,因此E-Mails必须通过WML表单来解决。例如:

<wml>
     <card id="edit" title="Email Editor">
      <p>From: <input type="text" name="from" format="*M"/></p>
      <p>To: <input type="text" name="to" format="*M"/></p>
      <p>Subject: <input type="text" name="subject" format="*M"/></p>
      <p>Message body: <input type="text" name="body" format="*M"/></p>
      <p>
        <anchor>Send this mail
          <go method="post" href="http://some.host/mailhandler"?action=send/">
            <postfield name="from" value="$(from)"/>
            <postfield name="to" value="$(to)"/>
            <postfield name="subject" value="$(subject)"/>
            <postfield name="body" value="$(body)"/>
          </go>
       </anchor>
      </p>
   </card>
</wml>
在代码中的http://some.host/mailhandler是一个CGI程序,它是服务端的脚本程序,将提交的表单转换成E-Mail格式并发送出去。
如果想使用一个类似于发信的过程,就需要编辑变量名。另外发送的数据是有限的,长信息可能需要打断。
开发者需要一个WAP网关吗?

不是很必要。如果只想进行简单的WAP内容服务,可以使用现有的Web服务器(只需要修改MIME类型)。移动电话会通过坐落在本地的网关连接到你的服务器上。
但是在网关上驻留开发者的程序有很多好处。既然开发者的程序是网关的一个部分,开发者就可以知道呼叫号码、身份、位置等等。

5. 可以看到WML的源代码么?

如果开发者使用SDK浏览的时候将能够看到WML的代码。如果只有一个HTML浏览器,可以访问"Fetch Page"服务(http://www.webcab.de)来取得代码。这个可以显示在Internet上的任何WML页面中。

27. 怎样防止从Cache中读取WML页面?

<%
    Response.ContentType = "text/vnd.wap.wml"
    Response.Expires = -1
    Response.AddHeader "Pragma", "no-cache"
    Response.AddHeader "Cache-Control", "no-cache, must-revalidate"
%> 
使用META的例子经过86400秒(24 hours)后过期:
<?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 forua="true" http-equiv="Cache-Control" content="max-age=86400"/>
    </head>
    <card id="expire1day">
      <p>This card will live in the cache for a day</p>
    </card>
  </wml>

用户手机号码和手机型号均在HTTP的HEADER中包含,说明如下。
(1) 用户手机号码
(2) 手机型号
必须要电信部门批准的Sp/Cp才可以

如何使用WAP设备发送E-Mail?
在HTML中有一个默认的E-Mail机制:" mailto:" 。但在WML中不好使,因此E-Mails必须通过WML表单来解决。例如:

<wml>
     <card id="edit" title="Email Editor">
      <p>From: <input type="text" name="from" format="*M"/></p>
      <p>To: <input type="text" name="to" format="*M"/></p>
      <p>Subject: <input type="text" name="subject" format="*M"/></p>
      <p>Message body: <input type="text" name="body" format="*M"/></p>
      <p>
        <anchor>Send this mail
          <go method="post" href="http://some.host/mailhandler"?action=send/">
            <postfield name="from" value="$(from)"/>
            <postfield name="to" value="$(to)"/>
            <postfield name="subject" value="$(subject)"/>
            <postfield name="body" value="$(body)"/>
          </go>
       </anchor>
      </p>
   </card>
</wml>

怎么能够知道请求是从WML浏览器来的还是HTML浏览器来的?

获取HTTP_ACCEPT值,判断是否为"VND.WAP.WML"
<%
Response.Buffer = TRUE
  Dim IsWap
  httpAccept = LCase(Request.ServerVariables("HTTP_ACCEPT"))
  if Instr(httpAccept,"wap") then
  IsWap=1
  Else Response.Redirect "/index.html" : Response.Flush : Response.End
End if
%>
<%Response.ContentType = "text/vnd.wap.wml"%><?xml version="1.0"?>
<%Response.Flush%>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"
"http://www.wapforum.org/DTD/wml_1.1.xml">
  <wml>
  <card id="redirect">
  <onevent type="onenterforward">
  <go href="/index.wml"/>
  </onevent>
  <p>
  <a href="/index.wml">enter</a>
  </p>
  </card>
  </wml>
  <%Response.Flush:Response.End%>

如何判断访问者是来自哪个浏览器或者移动电话?
可以通过检查HTTP_USER_AGENT标签来判断。例如试着使用Microsoft Internet Explorer访问一个站点的时候,HTTP_USER_AGENT将返回:Mozilla/4.0 (compatible;MSIE 5.0; Windows 98);在同样的情况下使用Nokia 7110访问这个站点,HTTP_USER_AGENT就会是:Nokia7110/1.0(04.73)。据此可以判断用户代理是什么类型的。

2. 利用Wap页面进行直接拨打电话号码
把下边的代码放到:<p></p>之间。
<input name="phone_no" format="*m" value="13"/>
<do type="option" label="呼出号">
<go href="wtai://wp/mc;$(phone_no)"/>
</do><br/>
或者直接写入电话号码的方式:
<a href="wtai://wp/mc;1331597312*">拨打电话</a>
3. Asp中Gb2312转UTF-8程序
把下面的代码粘贴到ASP+WMl的文件中。
<%
Function uni(Chinese)
For i = 1 to Len (Chinese)
a=Mid(Chinese, i, 1)
uni=uni & "&#x" & Hex(Ascw(a)) & ";"
next
End Function
%>
使用方法:
<a title="<%=Uni("确定")%>" href="http://www.51omeng.com/bicyle/bikewap/index.asp"><%=Uni("欢迎光临被爱可以")%></a><br/>

<do type="prev" name="Prev" label="后退"><prev/></do>

我的wap开发经验总结

1. 错误连接
response.write "<a href='http://m2p.cn/txl.asp?mobileno="&mobilenum&”&file="&file&”'>通讯录</a>"
& 替换 &
response.write "<a href='http://m2p.cn/txl.asp?mobileno="&mobileno&"&page="&s2-1&"&file="&file&"'>上一页</a>"

2. 不能传递中文,需要编码
''用URLEncode方法进行编码
strurlencode=server.URLEncode(str) //能够取出中文
例如:response.write "<a href='http://m2p.cn/kjj.asp?mobileno="&mobileno&"&host="&host&"&comm="&server.URLEncode(mid(v(2*i+1),1,j-1))&"'>"&mid(v(2*i+1),j+1,len(v(2*i+1))-j)&"</a>"
''用HTMLEncode方法进行编码
strhtmlencode=server.HTMLEncode (str)
拨打电话
<a href='"&"wtai://wp/mc;"&mid(v(2*i+1),1,j-1)&"'>"&mid(v(2*i+1),j+1,len(v(2*i+1))-j)&"</a>"
3. Wap不保存cashe,强制刷新
<meta http-equiv="Cache-Control" content="max-age=0" />
<meta http-equiv="Cache-control" content="no-cache" />

5.按键上加连接

<do type="options" label="回首页">
<go href="http://wap.un165.com/" />
</do>
4. 常见错误
m3gate命令提示
Fatal Error. Ln 10 .Col 10
Expected end of tag ‘p’
response.write "命令已执行</br>"

正确写法
response.write “命令已执行”
response.write “<br/>”

5. 同一连接wap不能重复操作

文本需要翻页,因为每一次点击”下一页”传递的连接是相同的

手机不执行重复操做
解决:方法 添加一个动态参数 &time=now

6. 对于wap的自动换行
<p mode='nowrap'>强制不让系统自动换行

自动刷新

<card id="c1" ontimer="#c1">
<timer value="20"/>
<p align="center">
test card1
</p>
</card>

右返回软键

<do type="options" label="返回" name="home">
<spawn href="XXX.wml">
</do>

利用Wap页面进行直接拨打电话号码

2. 利用Wap页面进行直接拨打电话号码
把下边的代码放到:<p></p>之间。
<input name="phone_no" format="*m" value="13"/>
<do type="option" label="呼出号">
<go href="wtai://wp/mc;$(phone_no)"/>
</do><br/>
或者直接写入电话号码的方式:
<a href="wtai://wp/mc;1331597312*">拨打电话</a>
3. Asp中Gb2312转UTF-8程序
把下面的代码粘贴到ASP+WMl的文件中。
<%
Function uni(Chinese)
For i = 1 to Len (Chinese)
a=Mid(Chinese, i, 1)
uni=uni & "&#x" & Hex(Ascw(a)) & ";"
next
End Function
%>
使用方法:
<a title="<%=Uni("确定")%>" href="http://www.51omeng.com/bicyle/bikewap/index.asp"><%=Uni("欢迎光临被爱可以")%></a><br/>

wap服务器配置
text/vnd.wap.wml wml image/vnd.wap.wbmp wbmp
text/vnd.wap.wmls wmls
application/vnd.wap.wmlc wmlc
application/vnd.wap.wmlscriptc wmlsc
text/vnd.wap.wmlscript wsc
text/vnd.wap.wmlscript wmlscript

OTA配置
application/java-archive jar
text/vnd.sun.j2me.app-descriptor jad

获取wml源代码

http://webcab.de/fetchpage.htm

 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值