16. WMLScript Dialogs
Dialogs standard library contains three functions -- alert(),
confirm() and prompt(). They are used to display alert
messages, confirmation messages and input boxes to users. They can
help reduce the number of trips to the WAP server. For example, let's
say we have a WMLScript function that is used to check whether a
certain variable's value is in the range 1 to 100. If it is outside
the range, we will give the user a message to ask him/her to enter
again. The message is stored in a WML document.
if (number <
the above script, if number
is not in the range 1 to 100, the WML browser has to download the WML
from the WAP server, which involves a round-trip.
we rewrite the above script using the alert()
function of the Dialogs
standard library, like this:
if (number <
Dialogs.alert("Number too small. Please enter
else if (number >
Dialogs.alert("Number too large. Please enter
script instructs the WML browser to generate an alert message if
number is out of
range, which means the WML browser does not need to download the WML
from the WAP server any more. Hence, a round-trip to the WAP server
is saved and the WML browser will give a quicker response.
can learn how to use the three functions of the Dialogs standard
library in the following sections.
Feedback Form (ExpandCollapse