Java Reference
In-Depth Information
URL —This library contains a set of functions for handling both absolute and relative
URLs. Typical functions include getPath() , getReferer() , and getHost() .
WMLBrowser —This library contains functions by which WMLScript can access the asso-
ciated WML context. These functions must not have any side effects and must return
invalid in cases where the system does not support WMLBrowser and where the inter-
preter is not invoked by the WML Browser. Commonly used functions in this library
include go() , prev() , next() , getCurrentCard() , and refresh() .
Dialogs —This library contains a set of typical user interface functions including
prompt() , confirm() , and alert() .
In the following example, we will make use of some of the capabilities of the standard
libraries. For a complete listing of the libraries, see Appendix G, “WML Script Language
Reference.”
WMLScript Example
Listing 24.3 defines three functions in a file named WMLScriptExample.wmls . These functions
are: setvar() , getString() , and getLength() . As you can see, these functions make use of
the WMLBrowser and String standard libraries to access the helper functions in these libraries.
Each of the functions takes a variable, sets it in the browser, and then returns focus to the
browser.
L ISTING 24.3
WMLScriptExample.wmls
/*
* This function simply sets a variable and transfers
* focus to the setvar_output card
*/
24
function setVar()
{
var output = “Hi There!”;
//Now set the variable in the browser environment
WMLBrowser.setVar(“txtOutput”, output);
//Now transfer focus to the setvar_output card
WMLBrowser.go(“#setvar_output”);
}
/*
* This function accepts a string and returns it to another card
*/
 
Search WWH ::




Custom Search