An event in WML is simply something that can happen to some element from time to time. For example, entering a <card> element triggers an event on the <card>, and selecting an <option> from a selection list triggers an event on the <option>.

You can harness these events by binding them to a task. The usual way of doing this is with the <onevent> element. As mentioned earlier in this chapter, for simple <go> tasks you can usually make use of a simpler form: this will be mentioned when when we discuss the elements in question.

For example, the <option> element (detailed in Chapter 4) declares an item in a list of selections. When this item is selected, it triggers an onpick event on the <option> element. Suppose the element were declared without an event handler, like this:


In this case, the onpick event is ignored, since there is no handler. If, on the other hand, the option is declared as:

    <onevent type="onpick">
        <go href="#purple"/>


the onpick event is handled by executing the <go> task, sending the browser to a new card.

The <onevent> Element

The <onevent> element declares an event binding. It can’t contain anything except a single task element that is performed when the event occurs. It may be present inside either an <option> element (see Chapter 4) or a <card> element (see Chapter 6). In either case, the <onevent> element (or elements) must be the first elements declared inside their enclosing element.

The ...

Get Learning WML, and WMLScript now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.