WML <onenterforward> Event
The onenterforward event is triggered when a user goes to a card in the forward direction. For example, if you go to a card by entering the URL directly or by following an anchor link of which the action is <go>, the onenterforward event will be triggered and the WML code associated with the event will be executed.
The onenterforward event will be useful to you if you want to do something before a card is displayed. For example, you need the onenterforward event if you want to assign a value to a variable before a card is displayed.
Here is the syntax to define an event handler for onenterforward event:
<onevent type="onenterforward"> A task to be performed. </onevent>
Following is the example showing how onenterbackward event occurs whenever you try to go on second card from the first card and defined event handler takes you to card number three instead of card number 2. Copy and paste this program and try to play with it to understand onenterforward event type.
<?xml version="1.0"?> <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.2//EN" "http://www.wapforum.org/DTD/wml12.dtd"> <wml> <card id="card1" title="Card 1"> <p> <anchor> <go href="#card2"/> Go to card 2 </anchor> </p> </card> <card id="card2" title="Card 2"> <onevent type="onenterforward"> <go href="#card3"/> </onevent> <p> This is card 2 </p> </card> <card id="card3" title="Card 3"> <p> Hello World! </p> </card> </wml>
When you load this program you will get the following screen:
Now, press option Go to card 2 to go to the second card, because of this onenterforward event will occur and it will take on card number 3 instead of card number 2 and you will see the following screen: