Slide 11.23: WML tasks (cont.)
  Slide 12.1: WMLScript
  Home


WML ONEVENT and TEMPLATE Tags


ONEVENT Tag
The <onevent> tag serves as a container for code that you wish to be executed automatically when one of the four intrinsic events occurs. The <onevent> element is said to bind (associate) the tasks (code) to the event for the element. You must specify the intrinsic event by using the mandatory type attribute. The four intrinsic events are given in the following table.

 Event   Permitted Tags   Description 
onenterbackward card or template Occurs when a prev navigates back into a card
onenterforward card or template Occurs when a go navigates back into a card
onpick option Occurs when an item is selected or unselected by a user
ontimer card or template Occurs when the timer expires

Note that this example does not work on the TagTag microbrowser.




 


TEMPLATE Tag
The <template> tag creates a code template that is automatically added to every card in a single deck. Only one <template> element can occur per deck. This tag can only be contained in a <wml> element. It can only contain <do> and <onevent> elements. The individual <card> elements can override the behavior specified by the <template> element. The behavior specified in a <template> element by a <do> element can be overridden in a <card> element by another <do> element, but only if both <do> elements have the same name for the <name> attribute. Likewise, the behavior specified in a <template> element by an <onevent> element can be overridden in a <card> element by using the onenterbackward, onenterforward, and ontimer attributes.