O'Reilly logo

Learning WML, and WMLScript by Martin Frost

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The <do> Element

The <input> and <select> elements provide high-level user controls, but sometimes all you want is a simple button or menu item. In these cases, the <do> element is exactly what you need.

A <do> element is simply a way to specify some arbitrary type of control for the browser to make available to the user. This can be rendered as a graphical button (as many PDA browsers do), as an item in a menu (as most cell phone browsers do), or as just about anything the user can know about and interact with. This can even include things such as voice commands for a hands-off WAP browser (in a car, for example).

A <do> element contains nothing but the task to be performed when the element is activated.

Attributes of the <do> Element

type (required string)

Specifies the type of this <do> element. This serves as a hint to the browser about the action this element triggers and may influence how the browser chooses to present the element. The following values are defined (undefined or unrecognized types are treated as if they had been specified as unknown):

accept

Acceptance of something. cell phones often bind this to the “yes” key if there is only one <do> of this type in the card.

prev

Navigation backwards in the history stack (a <prev> task or something similar).

help

Request for some sort of help. The help provided can be context-sensitive.

reset

An operation that clears or resets the state of the interaction; for example, a “clear and start over” operation on a group of text fields or an operation to deselect all options in a <select> element.

options

A context-sensitive request for additional options; for example, a button to bring up an “advanced options” menu.

delete

Delete a single item or choice. To delete all items, use the reset type instead.

unknown (or empty string)

A generic element that doesn’t fit any existing category.

Any name starting with X- or x-

Experimental types. The exact behavior of these is undefined. Some browsers may implement some of these for development purposes. These types shouldn’t be used in production systems.

Any name starting with vnd. (case-insensitive)

Vendor-specific types. Some browsers may implement specific <do> types of this form. Using these types allows you to enhance your WML for a specific browser, while remaining portable to others (unrecognized types are treated as if they were specified unknown).

label (optional variable string)

Specifies an optional text label for the element. For example, a browser that displays <do> elements as graphical buttons can use this as the button’s text. The WAP specifications recommend that to work well on the widest possible variety of browsers, this string should be limited to no more than six characters, but this rule isn’t enforced.

name (optional name)

Specifies the name of this element, for the purposes of shadowing (see Chapter 6, for more on shadowing). This type has no other effect.

optional (optional boolean; default false)

If set to true, informs the browser that it can ignore this <do> element.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required