选择显示字体大小

wml学习(六)

事件

  wml的事件基本上分为两大类,一类是键盘(包括软硬按钮)输入事件,用<do>标签来处理,另一类是相关页面内部的事件,用<onevent>标签来处理。

  <do>的语法如下:<do type="type" label="label" name="name" optional="falsetrue">任务</do>,任务就是以前提到的四种任务。<do>的属性中,type是必选的,其他为可选。
  *label属性,指定了软按钮在屏幕上的显示文本。目前type属性为delete,help,prev时该属性无效。 
  *name属性,为<do>取个名字,同一的card里的<do>不能重名。如果card级的<do>和deck级的<do>同名,则覆盖deck级的<do>。
  *optional属性,指定手机是不是可以忽略这个事件,默认值是false。
  *type属性,指定触发的事件,具体如下;
  type值    触发原因
  accept    调用accept按钮机制
  delete    调用delete按钮机制
  help     调用help按钮机制
  options   调用选择按钮机制
  prev     调用prev按钮机制
  reset    调用清除和重新设定手机状态时的reset机制(目前不支持)
  unknown    调用unknown机制,等于type=""(目前不支持)
  vnd. co-type 调用厂商特定的机制(目前不支持)
  x-*, x-*   供以后使用(不保留)(目前不支持)

test6.wml
---------------
<?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="card0" ordered="false">
<do type="accept" label="inputname" name="do1">
<go href="#card01"/>
</do>
<p>
name:<input name="username" title="user name" type="text" format="*m" emptyok="false" maxlength="12"/>
</p>
</card>
<card id="card01">
<p>
you name is &#36;(username:noesc).
</p>
</card>
</wml>

  <onevent>的语法如下,<onevent type="type">任务</onevent>,必选属性type的取值如下:
  type值     如果用户执行了以下操作就执行任务
  onpick     用户选择或不选一个<option>项时。
  onenterforward 用户使用<go>任务到达一个card时。
  onenterbackward 用户使用<prev>任务返回到前面的card时,或者按back按钮时。
  ontimer     当<timer>过期时。

test7.wml
---------------
<?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="card0" ordered="false">
<p>
please select a city...
<select title="cities list" name="city">
<option title="beijing" value="beijing">
<onevent type="onpick">
<go href="#card01"/>
</onevent>beijing</option>
<option title="shanghai" value="shanghai" onpick="#card01">shanghai</option>
<option title="hongkong" value="hongkong" onpick="#card01">hongkong</option>
</select>
</p>
</card>
<card id="card01">
<p>
you are living in &#36;(city:noesc)
</p>
</card>
</wml>

  <timer/>可以用来在用户不进行任何操作的一段时间后,自动执行一个任务,任何激活card页面的任务和用户操作都会启动<timer/>,而任务进行时,<timer/>就停止。每个card只能有一个<timer/>,一个<timer/>只能触发一个任务。语法如下:<timer name="variable" value="value"/>,其中name为可选属性,指定为一个变量名,当退出该card时,该变量存储此时定时器的值,当定时器超时时,手机将该变量设为0;value为必选属性,用来设置定时器的定时值,最小单位为0.1秒。

test8.wml
---------------
<?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="card1" ontimer="#card2">
<timer name="time1" value="50"/>
<p align="center">
after 5s, goto card2
</p>
</card>
<card id="card2">
<onevent type="ontimer">
<go href="#card1"/>
</onevent>
<timer name="time2" value="50"/>
<p align="center">
here is card2!
</p>
</card>
</wml>

  再提一下,<onevent> <timer> <do>三者必须按以上顺序写。

  此外在deck级还可以加入<template>,用来将事件捆绑在deck级上,语法如下:
  <template onenterforward="url" onenterbackward="url" ontimer="url">
  <do>或者<onevent>
  </template>


test9.wml
---------------
<?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>
<template>
<do type="accept" label="deckpress" name="do1">
<go href="#card01"/>
</do>
</template>
<card id="card0" ordered="false">
<do type="accept" label="cardpress" name="do1">
<go href="#card02"/>
</do>
<p>
press accept...
</p>
</card>
<card id="card01">
<p>
here is card01
</p>
</card>
<card id="card02">
<p>
here is card02
</p>
</card>
</wml>


 


关键字 本文所属关键字

相关 与本文相关文章

分类 所有文章关键字导航

源码编程相关

Java   Asp   PHP   .Net   XML   C/C++   CGI   VB   Jsp   J2ee   J2se   J2me   EJB   Servlet   Tomcat   Resin   Struts   Weblogic   Eclipse   ANT   GUI   JMS   Web servise   IDEA   Webphere   Hibernate   Spring   Jboss   Applet   Swing   Socket   Javamail   Perl   Ajax   P2P   安全   模式   框架   测试   开源   游戏

SQL数据库相关

My-SQL   Ms-SQL   Access   DB2   Oracle   Sybase   SQLserver   索引   存储过程   加密   数据库   分页   视图  

手机无线相关

3G   Wap   CDMA   GRPS   GSM   IVR   彩信   短信   无线   增值业务

网页设计制作相关

HTML   CSS   网页配色   网页特效   Javascript   VBscript   Dreamweaver   Frontpage   JS   Web   网站设计

网站建设推广相关

建站经验   网站优化   网站排名   推广   Alexa

操作系统/服务器相关

Windows XP   Windows 2000   Windows 2003   Windows Me   Windows 9.x   Linux   UNIX   注册表   操作系统   服务器   应用服务器

图形图像多媒体相关

Photoshop   Fireworks   Flash   Coreldraw   Illustrator   Freehand   Photoimpact   多媒体   图形图像

标准 网站致力的规范

Valid CSS!

无不良内容,无不良广告,无恶意代码

Valid XHTML 1.0 Transitional

creativecommons