WML learning 6 events

Source: Internet
Author: User

Event

WML events are basically divided into two categories: keyboard (including soft and hard buttons) input events, processed using the <do> tag, and related page events, use the <onevent> label for processing.

<Do> Syntax: <do type = "type" label = "label" name = "name" optional = "false | true"> task </do>, A task is one of the four previously mentioned tasks. In the <do> attribute, type is mandatory, and others are optional.

* Label attribute, which specifies the text displayed by the soft button on the screen. The current type attribute is delete, help, And prev, which is invalid.

* Name attribute, Which is <do> name. The <do> name in the same CARD cannot be duplicate. If the <do> and <do> of the CARD level have the same name, the <do> of the DECK level is overwritten.

* The optional attribute specifies whether the mobile phone can ignore this event. The default value is false.

* Type attribute, specifying the event to be triggered, as shown in the following code;

Reason for triggering the type value

Accept Calls the ACCEPT button Mechanism

Delete: Call the DELETE button Mechanism

Help call the HELP button Mechanism

Options call the select button Mechanism

Prev call the PREV button Mechanism

The reset mechanism when the RESET Call clears and resets the mobile phone status (not supported currently)

Unknown calls the unknown mechanism, which is equal to type = "" (not supported currently)

Vnd. co-type calls vendor-specific mechanisms (not supported currently)

X-*, x-* for future use (not retained) (not supported currently)

Test6.wml

---------------

<? Xml version = "1.0"?>

<! DOCTYPE wml PUBLIC "-// WAPFORUM // dtd wml 1.1 //" 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 $ (userName: noesc ).

</P>

</Card>

</Wml>

The <onevent> syntax is as follows: <onevent type = "type"> task </onevent>. The value of the required attribute type is as follows:

Type value: if the user executes the following operations, the task will be executed.

When onpick selects or does not select a <option> item.

Onenterforward users use the <go> task to arrive at a CARD.

When the onenterbackward user uses the <prev> task to return to the previous CARD, or presses the BACK button.

Ontimer when <timer> expires.

Test7.wml

---------------

<? Xml version = "1.0"?>

<! DOCTYPE wml PUBLIC "-// WAPFORUM // dtd wml 1.1 //" 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>

& Lt;/p>

</Card>

<Card id = "card01">

<P>

You are Living in $ (city: noesc)

</P>

</Card>

</Wml>

<Timer/> it can be used to automatically execute a task after the user does not perform any operation for a period of time. Any task that activates the CARD page and user operations will start <timer/>, when the task is in progress, <timer/> stops. Each CARD can have only one <timer/> and one <timer/> can trigger only one task. Syntax: <timer name = "variable" value = "value"/> where name is an optional attribute and is specified as a variable name. When you exit the CARD, this variable stores the timer value at this time. When the timer times out, the mobile phone sets this variable to 0; value is a required attribute, used to set the timer value of the timer, the minimum unit is 0.1 seconds.

Test8.wml

---------------

<? Xml version = "1.0"?>

<! DOCTYPE wml PUBLIC "-// WAPFORUM // dtd wml 1.1 //" 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">

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> must be written in the above Order.

In addition, you can add <template> at the DECK level to bind events to the DECK level. The syntax is as follows:

<Template onenterforward = "url" onenterbackward = "url" ontimer = "url">

<Do> or <onevent>

</Template>

Test9.wml

---------------

<? Xml version = "1.0"?>

<! DOCTYPE wml PUBLIC "-// WAPFORUM // dtd wml 1.1 //" 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>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.