In WML, you can use timers to perform timed actions. A timer measures a time period, and the browser undertakes some action when that period has expired . For example, if I assign a card's ontimer attribute to the ID of another card, the browser will navigate to that card when the timer finishes: <?xml version="1.0"?> <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 2.0//EN" "http://www.wapforum.org/dtd/wml20.dtd" > <wml> <card id="Card1" ontimer="#card2" title="Timers"> . . . </card> . . . You create a timer with the <timer> element and give it a time period (measured in tenths of seconds) with the value attribute, like this, where I'm giving this card's timer a period of 10 seconds: <?xml version="1.0"?> <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 2.0//EN" "http://www.wapforum.org/dtd/wml20.dtd" > <wml> <card id="Card1" ontimer="#card2" title="Timers"> <p align="center"><b>Timers</b></p> <timer value="100"/> <p> In ten seconds, you'll be redirected to the second card. </p> </card> . . . All that remains is to add the targeted card, card2: Listing ch20_18.wml<?xml version="1.0"?> <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 2.0//EN" "http://www.wapforum.org/dtd/wml20.dtd" > <wml> <card id="Card1" ontimer="#card2" title="Timers"> <p align="center"><b>Timers</b></p> <timer value="100"/> <p> In ten seconds, you'll be redirected to the second card. </p> </card> <card id="card2" title="Welcome"> <p> Welcome to card 2. </p> </card> </wml> Now when you open this deck, you'll see card 1, as shown in Figure 20-17. After 10 seconds, the browser will navigate to card 2. (Note that, as shown in the figure, Klondike features a timer counter at lower right; here, it's indicating that there are 7 seconds left in the timer.) Figure 20-17. Using a timer.
|