How to Call a WMLScript from a WML Page


Notice that WMLScripts are not embedded in WML pages. The WML pages only contains references to script URLs. In the example below, if you select the go label the external script will direct you to http://www.bbc.co.uk/mobile:




 

The example above contains a reference to a WMLScript. The script is in a file called Example.wmls, and the name of the function is Go_url. The WMLScript library function WMLBrowser is composed of seven functions that can be used to access the WML context. The function go orders the browser to load the given URL.

 http://people.cs.und.edu/~wenchen/course/handheld/wml/Example.wmls 

extern function  Go_url( the_url ) {
  if ( the_url == "BBC" ) {
    WMLBrowser.go( "http://www.bbc.co.uk/mobile" )
  }
}


Note that the function is using the extern keyword. When using this keyword the function can be called by other functions or WML events outside the .wmls file. To keep a function private, drop the extern keyword.