本節說明 WML 的內部事件(Onevent)及其觸發條件。
相關屬性 type 是內部事件的觸發條件,當瀏覽器狀態滿足觸發條件時,就會觸發該條件下設置的 Task。內部事件共有 4 種觸發條件:
<?XML version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"
"https://www.wapforum.org/DTD/wml_1.1.XML">
<wml>
<!-- this deck can't use in Ericsson r320sc, because r320sc haven't accept button-->
<card id="start">
<do type="accept" label="next">
<go href="#two"/>
</do>
<p>This is the first card.</p>
</card>
<card id="two">
<do type="accept" label="next">
<go href="#three"/>
</do>
<onevent type="onenterbackward">
<go href="#temp"/>
</onevent>
<p>This is the second card.</p>
</card>
<card id="three">
<do type="accept" label="back">
<prev/>
</do>
<p>This is the third card.</p>
</card>
<card id="temp">
<do type="accept" label="start">
<go href="#first"/>
</do>
<p>haha, you are lost!</p>
</card>
</wml>
在上例中,當使用者從第二張卡片透過 prev 返回時,會觸發 onenterbackward 事件,進而跳轉到 temp 卡片,示範了事件如何攔截並改變預設的導航行為。