Welcome to Developer's Home Thursday, April 17, 2014
Home - DevelopersHome.com

WMLScript URL Standard Library


Preferences - Do not show ads

WMLScript's URL standard library contains functions for manipulating URLs.

In the following sections, we will look at some of the more commonly used functions in the URL standard library.


Getting the Current WMLScript Document's URL: getBase() Function

The getBase() function of the URL standard library is used to get the current WMLScript document's URL without the fragment part (the fragment of a URL is the part that begins with the # character). Note that the URL returned is always in the absolute form.

The following WML/WMLScript example demonstrates the use of the getBase() function. Let's say we have a WML document that contains the markup below:


<card id="card1" title="Card 1">
  <p>
    <anchor>
      <go method="get" href="tutorial_eg.wmls#func1()">
        <postfield name="x" value="abc"/>
        <postfield name="y" value="123"/>
      </go>
      Run WMLScript
    </anchor>
  </p>
</card>


If we open the WML card in a WAP browser and select the "Run WMLScript" anchor link, the func1() function in the WMLScript file tutorial_eg.wmls will be executed. Below shows the script included in the tutorial_eg.wmls file:


extern function func1()
{
  var url_str = URL.getBase();
}


func1() contains only a single line of statement. After the statement is executed, the url_str variable has the string value "http://www.developershome.com/examples/wmlscript/tutorial_eg.wmls?x=abc&y=123". (Suppose the tutorial_eg.wmls file is stored in the directory "examples/wmlscript/" of the host "www.developershome.com".)

We can further extract the query string in the url_str variable using the getQuery() function, which will be covered in this tutorial later.


Page 62 of 71 Previous Page | Next Page
Contents at a Glance
Print this Web Page | | Back to Top
Custom Search

Feedback Form (Expand)

What do you think about this web page?






WMLScript Tutorial Table of Contents WMLScript Tutorial Contents at a Glance Preferences - Change Color Scheme Preferences - Do Not Show Ads Previous Page Next Page