WML
Event: onenterbackward
The
onenterbackward event is triggered if a user goes back to a
previous card through the WAP browser's URL history, and the WML code
placed in the event handler will be executed.
The
following WML example shows a situation in which the onenterbackward
event has to be used. It is used to prevent a user from going back to
a particular card. What we want to do is like this: We want to place
an advertisement in an intermediate card between the table of
contents and the chapters of a WML tutorial. If a user navigates to a
chapter from the table of contents, an advertisement will appear for
a few seconds. Later if the user presses the Back button to go back
to the table of contents, the WAP browser will not display the
advertisement again so as to reduce the disturbance to the user.
(onenterbackwardEg1.wml)
<?xml
version="1.0"?> <!DOCTYPE wml PUBLIC
"-//WAPFORUM//DTD WML 1.3//EN"
"http://www.wapforum.org/DTD/wml13.dtd">
<wml> <card
id="tutorial_tc" title="WML
Tutorial"> <p> Hello, welcome to our
WML tutorial.<br/><br/> Table of
Contents:<br/>
<a
href="#tutorial_ch1_ad">Chapter 1: WML
Introduction</a><br/>
<a
href="#tutorial_ch2_ad">Chapter 2: WML Deck and
Card</a><br/><br/>
... </p> </card>
<card
id="tutorial_ch1_ad" title="Advertisement"> <onevent
type="onenterbackward"> <prev/> </onevent> <onevent
type="ontimer"> <go
href="#tutorial_ch1"/> </onevent> <timer
value="30"/> <p> <a
href="http://12345site.com/">Click here to download our
free ringtones, wallpapers, mobile games and MP3 songs
now.</a><br/><br/> <a
href="#tutorial_ch1">Skip</a> </p> </card>
<card
id="tutorial_ch2_ad" title="Advertisement"> <onevent
type="onenterbackward"> <prev/> </onevent> <onevent
type="ontimer"> <go
href="#tutorial_ch2"/> </onevent> <timer
value="30"/> <p> <a
href="http://67890site.com/">Click here to buy
WAP-enabled cell phones online now. Free
shipping.</a><br/><br/> <a
href="#tutorial_ch2">Skip</a> </p> </card>
<card
id="tutorial_ch1" title="WML Tutorial
Ch1"> <p> <em>Chapter 1: WML
Introduction</em><br/><br/> ...<br/> <anchor> <prev/> Go
Back </anchor> </p> </card>
<card
id="tutorial_ch2" title="WML Tutorial
Ch2"> <p> <em>Chapter 2: WML Deck
and
Card</em><br/><br/> ...<br/> <anchor> <prev/> Go
Back </anchor> </p> </card> </wml>
Below
shows the screenshots of the first card in some mobile phone
browsers. This card contains the table of contents of the tutorial.

 Sony
Ericsson T610
|


 Sony
Ericsson T68i
|

 Nokia
Mobile Browser 4.0
|
If
you select the "Chapter 1: WML Introduction" anchor link,
you will see an advertisement in the mobile phone browser, like this:

 Sony
Ericsson T610
|

 Sony
Ericsson T68i
|

 Nokia
Mobile Browser 4.0
|
If
you do not select the "Skip" anchor link, the mobile phone
browser will display Chapter 1 of the tutorial automatically after 3
seconds:
 Sony
Ericsson T610
|
 Sony
Ericsson T68i
|
 Nokia
Mobile Browser 4.0
|
If
you select the "Go Back" anchor link, the onenterbackward
event will be triggered when the advertisement card is loaded. The
WML code associated with the onenterbackward event, that is
<prev/>, will be executed. So, the mobile phone browser will go
backwards once more and you will see the table of contents instead of
the advertisement.
 Sony
Ericsson T610
|
 Sony
Ericsson T68i
|
 Nokia
Mobile Browser 4.0
|
Feedback Form (ExpandCollapse)
|
|