WML - 模板



<template> 用於將 <do> 和 <onevent> 元素應用於一副牌中的所有卡片。此元素定義一副牌中所有卡片的模板,<template> 標籤中的程式碼將新增到一副牌中的每張卡片中。

可以透過在 WML 卡片中定義另一個具有相同 name 屬性值的 <do> 元素來覆蓋模板的 <do> 元素。

<template> 元素支援以下屬性

屬性描述
onenterbackwardURL當用戶使用“prev”任務導航到卡片時發生
onenterforwardURL當用戶使用“go”任務導航到卡片時發生
ontimerURL當“定時器”到期時發生
class類資料設定元素的類名。
id元素 ID元素的唯一 ID。

以下是顯示 <go> 元素用法的示例。

<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.3//EN" 
"http://www.wapforum.org/DTD/wml13.dtd">

<wml>
  <template>
    <do name="main_menu" type="accept" label="Chapters">
      <go href="chapters"/>
    </do>
    <do name="menu_1" type="accept" label="Chapter 1">
      <go href="#chapter1"/>
    </do>
    <do name="menu_2" type="accept" label="Chapter 2">
      <go href="#chapter2"/>
    </do>
    <do name="menu_3" type="accept" label="Chapter 3">
      <go href="#chapter3"/>
    </do>
    <do name="menu_4" type="accept" label="Chapter 4">
      <go href="#chapter4"/>
    </do>
  </template>

  <card id="chapters" title="WML Tutorial">
    <p>
      Select One Chapter:<br/>
      <anchor>
        <go href="#chapter1"/>
        Chapter 1: WML Overview
      </anchor><br />

      <anchor>
        <go href="#chapter2"/>
        Chapter 2: WML Environment
      </anchor><br />

      <anchor>
        <go href="#chapter3"/>
        Chapter 3: WML Syntax
      </anchor><br />

      <anchor>
        <go href="#chapter4"/>
        Chapter 4: WML Elements
      </anchor><br />
    </p>
  </card>

  <card id="chapter1" title="WML Tutorial Ch1">
    <p>
      <em>Chapter 1: WML Introduction</em><br/>
      ...
    </p>
  </card>

  <card id="chapter2" title="WML Tutorial Ch2">
    <p>
      <em>Chapter 2: WML Environment</em><br/>
      ...
    </p>
  </card>

  <card id="chapter3" title="WML Tutorial Ch3">
    <p>
      <em>Chapter 3: WML Syntax</em><br/>
      ...
    </p>
  </card>

  <card id="chapter4" title="WML Tutorial Ch4">
    <p>
      <em>Chapter 4: WML Elements</em><br/>
      ...
    </p>
  </card>
</wml>

這將生成以下選單,現在您可以瀏覽所有章節

WAP Example 11
廣告

© . All rights reserved.