The Wireless Universal Resource File

The Wireless FAQ

7.12 How do I get a WML card to refresh itself?

Those of you who have some experience from the "web" environment will most likely have used the <meta http-equiv="refresh" content="1;"> tag to force a browser to load a new or the same page.

Although some META tags are supported in the WAP environment, a much better way of doing the exact same thing in WML is to use the <ontimer> tag.

The following piece of code will force the browser to load another deck after a certain time. For the example below, the deck will jump to another deck called nextdeck.wml.

  <?xml version="1.0"?>
  <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://...">
  <wml>
    <card id="splashscreen" ontimer="nextcard.wml">
      <timer value="40"/>
      <p>Please wait for the timer to run out...</p>
    </card>
  </wml>

The following piece of code will force the browser to reload the same card after a certain time. For the example below, the deck file is called loop.wml.

  <?xml version="1.0"?>
  <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://...">
  <wml>
    <card id="loop" ontimer="loop.wml">
      <timer value="40"/>
      <p>This text will be shown over and over again...</p>
    </card>
  </wml>

Note that for a browser to actually reload the same card, you will need to bypass the browser's caching mechanism, or else the card will be loaded from the browser's memory, and not from the server. Caching control is explained here.

[ Main ]   [ 07 - Making it look fancy ]