Currently supported metadata:
<meta http-equiv="Cache-Control" content="max-age=3600"/>
Specifies the storage time period for the page in the mobile phone memory cache, the default is 30 days (unless the memory is exhausted). During this period, the mobile phone calls the visited pages directly from the cache. If the information is time sensitive, you can use max-age to specify the lifetime of the page in the cache, with the minimum unit being seconds. If specified as 0, the page needs to be called by connecting to the server every time
<meta user-agent="" content="false"/>
<meta user-agent="" content="Specified URL"/>
Bookmarking function similar to ordinary browsers. When the user bookmarks a card, the mobile browser first records the card with a mark. The default value of this tag is the title attribute in the <card> tag (which will be discussed later). Then when the user selects the bookmark, the browser will open the recorded URL. But because by default, the phone will record all pages. Therefore, <meta> is generally used to prevent the mobile phone from recording the current URL, that is, <meta user-agent="" content="false"/>. In addition, if you want to specify a URL different from the current page for the bookmark, use <meta user-agent="" content="specified URL"/>.
A page can contain multiple cards, and the content of each card may be displayed more than one screen. Pay attention to the relationship between the page, card and screen display range. A card is included with <card> and</card>. <card> can contain the following optional properties:
<card title="label" newcontext="false" ordered="true" onenterforward="url" onenterbackward="url" ontimer="url">
The id attribute is used to specify the name of the card and can be used to jump between cards, which is equivalent to using <A NAME="jumpHere"> when jumping within the page in HTML.
The title attribute is used as a bookmark mark, and this attribute is generally not displayed on the screen.
The newcontext attribute (default is false) is used to indicate whether the phone needs to clear the previously retained information when jumping to this card. Including variables, history records in the stack, resetting the phone status, etc.
The ordered attribute (the default value is true) indicates whether the contents in the card are displayed in a fixed order or in the order of user selection. This is different from HTML, and the content in the card can be displayed in a certain order. The default is to display in linear order, that is, in the order of codes. However, it should be noted that the following three tags must be written in the following order: <onevent>, <timer>, <do> (this is related to the "event" to be discussed later). This is done to facilitate filling of forms. When ordered is set to true, if the content of a form cannot be displayed in one screen, it will be divided into multiple screens. When ordered is set to false, the phone can display a summary card to summarize the valid options, and users can select the form options from it to fill in.
The onXXXX attribute, similar to the onXXXX attribute in HTML tags, is used to capture events. When the event is triggered, the specified action (task) is performed, here it is to turn to a certain URL.
WML is basically the same as HTML in the display of text. Text fields are contained between <p align="alignment" mode="wrapmode"> and</p>. The align attribute specifies the alignment of the text in this segment, the default is left. Other options are available for right and center; mode attributes specify whether to automatically wrap lines when no text is displayed in one line. The default is wrap wrap. If you select nowrap, it will be displayed in one line and the browser will display all text through a mechanism similar to a horizontal scroll bar.
The same is true for newline tags. Let me first mention that if there are multiple <input> or <select> in the form, do not use <br/>, otherwise the mobile browser will paginate the form if it is a breakpoint.
The modified tags of text include <b>, <i>, <u>, <em>, <strong>, <big> and <small>, and the meaning is the same as in HTML.
The display tags of the table are also similar to HTML, and are displayed using <table title="name" align="left|right|center" columns="number of columns">, <tr> and <td>. The title attribute of <table> is used to name the table. The columns attribute specifies the number of columns in the table, and cannot be 0. The optional align attribute is the same as mentioned earlier. The table can contain text and pictures.
Please see the following example:
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"
"/DTD/wml_1.">
<wml>
<card>
<p align="center">
<i>Hello</i>
<b><i>World!</i></b>
<table title="mytable" align="right" columns="2">
<tr>
<td>1-1</td>
<td>1-2</td>
</tr>
<tr>
<td>2-1</td>
<td>2-2</td>
</tr>
</table>
</p>
</card>
</wml>
The tag that displays the picture (1-bit black and white BMP picture) is similar to HTML.
<img alt="text" src="url" localsrc="icon" align="left" height="n" width="n" vspace="n" hspace="n"/>
Attributes alt and src are required, and others are optional. It should also be noted that <img> should be placed in <p>, and cannot be placed in functional labels such as <do> and <option> and menu labels.
The alt attribute is used to specify the text to be displayed when the phone does not support image display.
The src attribute specifies the URL of the image, but when the following localsrc attribute is available, the mobile browser ignores the src attribute.
The localsrc attribute is used to specify the icons displayed in the mobile phone ROM. If they cannot be found, they will go to the Server to search.
The optional align attribute is used to indicate the alignment of the image with the current line of text. The default value is bottom, optional to and middle.
The height, width, vspace, and hspace attributes specify the length, width of the image and the spacing around text respectively. Currently, not all WAP phones support these attributes.
Please see the following example program:
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"
"/DTD/wml_1.">
<wml>
<card>
<p align="center"><img alt=":)" src="" localsrc="smileyface"/></p>
</card>
</wml>
Links are the most basic function in HTML pages. <a href="url" title="label"> and</a> are also used in WML to include the text used to create links. The required attribute href specifies the URL to be opened; the optional title attribute gives the link a tag name, which will be displayed as a marker for the ACCEPT key of one of the soft buttons in the soft button area of the screen, so the attribute can usually be used as prompt text.
However, the above link is only a case of tasks in WML. In order to be able to use other tasks, a new tag <anchor title="label">task tag text</anchor> was introduced. <a> is actually a simple representation when the task tag is <go/>.
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "/DTD/wml_1.">
<wml>
<card>
<p>
<anchor title="Link1"><go href=""/>News</anchor><br/>
<a title="Link2" href="">Sports</a>
</p>
</card>
</wml>
There are the following types of task tags in WML, which can be used in events in addition to being used in <anchor>:
<go> is used to instruct the browser to display the specified URL, including the first card of the page or the specified card. The syntax is as follows:
<go href="url" sendreferer="false|true" method="get|post" accept-charset="charset">
<postfield name="name" value="value"/>
<setvar name="name" value="value"/>
</go>
Among them, the href attribute is required and other attributes are optional.
The sendreferer attribute indicates whether to pass the URL of the page calling the URL specified by href. That is, the URL of the current page, that is, HTTP_REFERER in the HTTP header. The default value is false, and the optional value is true.
The method is the same as the method attribute of the form FORM in HTML, which specifies whether the form is submitted in the form get or post for CGI processing. The default value is get, but if the method is not specified but there is a <postfield> between <go> and </go>, the phone will automatically pass it in post.
The accept-charset property can override the character set specified in the HTTP header. Multiple character sets can be written, such as accept-charset="UTF-8,US-ASCII, ISO-8859-1".
<postfield name="name" value="value"/> can be regarded as <INPUT TYPE="HIDDEN" NAME="Variable Name" VALUE="value"> in the HTML form FORM, through which data in the form of "variable name/value" can be passed to the specified URL. Both name and value attributes are required. Note that only the variables here are used to submit to the CGI program.
In addition to <postfield>, you can also add one or more sentences between <go> and</go>. The meaning of this statement is to assign a value to the variable when an event is triggered.
It should be noted that when there is no statement between <go> and </go>, the form of <go> should be used, which is more special. For example: <anchor title="Link1"><go href=""/>News</anchor>.
<prev> Use to push the URL of the current page into the URL history stack and open the previous URL. If the URL does not exist, <prev> is invalid. Syntax similar to <go>:
<prev><setvar name="name" value="value"/></prev>
One or more sentences can be added between <setvar name="name" value="value"/>. If not added, it must become a form of <prev/>.
<refresh> Used to refresh the current page, so that the variables in the page are refreshed, the syntax is:
<refresh><setvar name="name" value="value"/></refresh>
<noop> means doing nothing. This tag cannot be used in <anchor>, but is generally used to overwrite page-level event templates.
Similar to HTML <FORM>. <fieldset> can be used to include a set of form options, but is not required. As mentioned earlier, when the ordered of <card> is set to false, the phone can display a summary card to summarize effective options, so that users can select form options from it to fill in. The summary card is summarized based on <fieldset> and independent input box <input> and menu <select>. The syntax is:
<fieldset title="label">form content</fieldset>
In addition to representing the name of the form, the optional title attribute is also used as the title of the selection in the summary card. The form content can be nested <fieldset>, input box <input>, menu <select> and necessary prompt text.
<input name="variable" title="label" type="type" value="value" default="default" format="specifier" emptyok="false|true" size="n" maxlength="n" tabindex="n"/> Used to enter text, except for the name attribute that is necessary, others are optional.
The name attribute specifies the name of the variable used to store the input text.
The title attribute, the name of the input box, can also be used as the option name in the summary card page.
The type attribute has the default value of text. If password is selected, the input data will be displayed as *.
The value attribute is syntactically and behaviorally equivalent to the default attribute below.
The default attribute specifies the default value of the input box, that is, the name attribute specifies the default value of the variable. When the user enters a new value, the value is invalid. If the value does not comply with the following format attribute requirements, the phone ignores the default value.
The format attribute is used to format the input data. The available marks are as follows. When used, you can use the form of "bit-digit mark" and "* mark". The former represents N mark-type characters, such as 3X, and the latter represents any (less than the value of the maxlength attribute) mark-type characters. Table 3-4 includes the enumeration values and their significance commonly used in format.
The maxlength attribute specifies the maximum character length that the user can enter, with a maximum limit of 256 characters.
The emptyok attribute indicates whether the user can not fill in the input box. The default is false, that is, it is to fill in.
The size attribute, the input box display length, is not supported at present.
The tabindex attribute is similar to which option the focus falls on after pressing the TAB key in an HTML form. This value determines the selection order, and the number with the largest number is ranked behind. Not supported yet.
Table 3-4 Format marks
Mark Description
A Any symbol or capital letter (excluding numbers)
a Any symbol or lowercase letter (excluding numbers)
N Any number (excluding symbols or letters)
X Any symbol, number or capital letter (cannot be changed to lowercase letters)
x Any symbol, number or lowercase letter (cannot be changed to uppercase letters)
M Any symbol, number or capital letter (can be changed to lowercase letters) or multiple characters, default to capital letters of the first character
m Any symbol, number or lowercase letter (can be changed to uppercase letters) or multiple characters, default to lowercase first character
To illustrate the impact of input format on users, please see the following example program:
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"
"/DTD/wml_1.">
<wml>
<card ordered="false">
<p>
USERNAME:<input name="userName" title="User Name" type="text" value="YourNameHere" format="*M" emptyok="false" maxlength="12" tabindex="1"/>
PASSWORD:<input name="password" title="Password" type="password" format="8x" emptyok="false" maxlength="8" tabindex="2"/>
COMMENTS:<input name="comments" title="comment" type="text" value="YourCommentsHere" format="*M" emptyok="true" maxlength="30" tabindex="3"/>
</p>
</card>
</wml>
Start Nokia WAP Toolkit and select "Open Location" under "Go". After entering the URL address, you can see the content on the emulator. Note that the cursor is in the edit box of PASSWORD by default.
Select "Options" to edit and press the button several times. Select "OK" before the input is not over 8, and the simulator will not respond in any way; after more than 8, you can no longer enter. This is where the 8x limit works. And since the PASSWORD input attribute type is "password", all displayed are "*********". It should be noted that when typing, don't try too fast, otherwise you will always switch on one character. If readers have used mobile phones, they should know this.
When deleting all characters, "Clear" becomes "Back". The emulator returns to the previous page.
When editing "User Name", I found that the input automatically becomes capitalized. This is because M works. If more than 12 characters are entered, then characters will not be entered any more. This is maxlength at work.
Of course, you can switch the input method to lowercase.
If you press "OK" at this time, then USERNAME will become "". This is because M is fronted by "*". It does not limit the number of input characters. However, if you clear all characters in "User Name" and then select "OK". This is emptyok at work. It requires at least one character to be entered. Readers can try it for themselves!
Change the ordered value in the above example <card> to "true", and then add <fieldset title="field1"> and</fieldset> to <p> and</p> and try. (Nokia WAP Toolkit seems to turn a blind eye to these changes...)
<select> is similar to <SELECT> in HTML forms. The <optgroup> and <option> tags can be included between <select> and </select>. The syntax is as follows, and all attributes are optional:
<select title="label" multiple="false|true" name="variable" default="default" iname="index_var" ivalue="default" tabindex="n">
<optgroup title="label">Men content</optgroup>
<option title="label" value="value" onpick="url"> event or text </option>
</select>
title attribute, such as the title attribute of <input> above.
The multiple attribute specifies whether the user can make multiple choices. The default value is false.
The name attribute is used to store the variable name of the user's selection, and its value is the value attribute of the <option> tag. If the user has no choice and does not specify the default value with the default attribute, the phone will assign the change value to an empty string (""). For multiple choices, each value is separated by ";".
The default attribute can be assigned a default value to the variable specified by the name attribute.
The iname attribute is used to record the location of the user's selection, and the corresponding value starts from 1. If not selected, the value is 0.
The ivalue attribute is used to record the default value.
<optgroup> can be used to group multiple <option>s, and <optgroup> and </optgroup> can also include <optgroup> and <option>. The tag is not currently supported.
<option>, similar to the <option> of a menu in HTML, is used to represent options for menus. The display text between <option> and </option> may include events and menus. The <option> property is optional, where the value property is used to provide the value. When this item is selected, assign the value to the variable specified by the name attribute of <select>. The onpick attribute is used to specify the URL of the page opened after the user selects this item and presses the ACCEPT key.
To illustrate how the selection works, see the following example:
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"
"/DTD/wml_1.">
<wml>
<card ordered="false">
<p>
Please select a city...
<select title="Cities List" name="city">
<option title="Beijing" value="c1">Beijing</option>
<option title="Shanghai" value="c2">Shanghai</option>
<option title="Hongkong" value="c3">Hongkong</option>
</select>
Please select columns...
<select title="Column List" multiple="true" name="col">
<option title="Hot News" value="l1">News</option>
<option title="Cool Sports" value="l2">Sports</option>
<option title="Pop Enter,,," value="l3">Entertainment</option>
</select>
</p>
</card>
</wml>
WML events are basically divided into two categories. One is keyboard (including soft and hard buttons) input events, which are handled using the <do> tag. Another type is events inside the relevant page, which are handled with the <onevent> tag.
The syntax of <do> is as follows:
<do type="type" label="label" name="name" optional="false|true">Task</do>
Tasks are the four tasks mentioned before. In the <do> attribute, type is required, and others are optional.
label attribute specifies the display text of the soft button on the screen. Currently, the type attribute is delete, help, or prev. This attribute is invalid.
name attribute, give a name for <do>. The <do> in the same card cannot be duplicated. If the card-level <do> and the page-level <do> have the same name, the page-level <do> will be overwritten.
optional attribute, specify whether the phone can ignore this event, the default value is false.
The type attribute specifies the triggered event, as shown in Table 3-5:
Table 3-5 Enumeration value of type
Enumeration value trigger reason
accept call ACCEPT button mechanism
delete calls DELETE button mechanism
help Calling the HELP button mechanism
options call selection button mechanism
prev Calling the PREV button mechanism
reset: The RESET mechanism when calling the clear and reset mobile phone status (not currently supported)
unknown calls unknown mechanism. Equivalent to type="" (not currently supported)
Vnd. co-type: Calling manufacturer-specific mechanisms (not currently supported)
X-*, x-* for future use (not retained) (not supported at present)
To demonstrate the triggering process of an event, please see the following example:
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"
"/DTD/wml_1.">
<wml>
<head>
<meta http-equiv="Cache-Control" content="max-age=0"/>
</head>
<card ordered="false">
<do type="accept" label="InputName" name="do1">
<go href="#card01"/>
</do>
<p>
NAME:<input name="userName" title="User Name" type="text" format="*M" emptyok="false" maxlength="12"/>
</p>
</card>
<card >
<p>
You name is $(userName:noesc).
</p>
</card>
</wml>
Previous page123Next pageRead the full text