The <timer> Element

A timer is declared inside a WML card with the <timer> element. It must follow the <onevent> elements if they are present. (If there are no <onevent> elements, the <timer> must be the first element inside the <card>.) No more than one <timer> may be present in a card.

The <timer> element takes two attributes:

name (optional name)

Name of a variable to use when initializing the timer. If this variable is set when the timer needs to be initialized, its value is used as the timeout. In addition, whenever the timer is stopped, the amount of time remaining is stored back into this variable. (If the timer expires, the value 0 is stored.)

value (required variable number)

Gives a default value for the timeout. This value is used if the name attribute isn’t present or the variable that it names isn’t set. If name is both present and names a variable containing a value, this attribute is ignored.

Timeouts are specified in units of a tenth of a second, but a particular browser may round them to some other precision internally. For example, a browser that can count only whole seconds can round all timeouts to the nearest second. If the initial timeout (from either the name variable or the value attribute) isn’t a positive integer, the timer is ignored.


Because of these considerations, it’s wise to always provide an alternative method of activating a timer’s task. For example, add a <do> element with the same task to the card.

The <refresh> task has particular relevance ...

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

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.