WML - ontimer Event



The ontimer event is used to trigger an event after a given time period. Let's say you want to display a message after 5 seconds of loading a card, then you can use this event to do so.

Here is the syntax to define an event handler for ontimer event:

<onevent type="ontimer">
   A task to be performed.
</onevent>
<timer value="50"/>

Here, it means that a task will be performed after 5 seconds.

Following is the example showing usage of ontimer event along with <onevent> element.

<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.2//EN"
"http://www.wapforum.org/DTD/wml12.dtd">

<wml>

<card id="splash" title="splash">
  <onevent type="ontimer">
    <go href="#welcome"/>
  </onevent>
  <timer value="50"/>
<p>
  <a href="#welcome">Enter</a>
</p>
</card>

<card id="welcome" title="Welcome">
<p>
Welcome to the main screen.
</p>
</card>
</wml>

When you load this program, it shows you the following screen:

WAP Exampple19

If you do not select given Enter option, then after 5 seconds you will be directed to Welcome page and following screen will be displayed automatically.

WAP Exampple20
wml_events.htm
Advertisements