WMLScript » URL » URL.loadString

Syntax:
URL.loadString(url, contentType)
url
The mandatory url parameter is the absolute URL of the target site.
contentType
The mandatory contentType parameter is of the syntax: type/subtype
The type prefix can only have the value of text. The subtype suffix can be any value.

Returns the content type based upon the provided absolute URL and content type/subtype.

The URL.loadString function takes the contents of the site that is found at the address of the given absolute URL and is of the specified content type, converts the contents to a string, and returns that string.

If the URL will not load, the browser will display an appropriate error code. If the content type is invalid, an invalid will be returned.

Examples

Code:
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"
"http://www.WAPforum.org/DTD/wml_1.1.xml">
<wml>

<card id="card1">
   <p>
   loadString example
   </p>
   <do type="accept">
      <go href="LoadStringExample.wmls#findloadstring()" />
   </do>
</card>

<card id="card2">
<p>
   URL = $(urlstring)
   <br />
   content type = $(contenttype);
   <br />
   load string = $(loadstr);
</p>
</card>

</wml>
Explanation:

Code for LoadStringExample.wml

Language(s): WML
Code:
extern function findloadstring()
{
   var urlstr = Dialogs.prompt("Enter URL", "");
   var ctype = Dialogs.prompt("Enter Content Type", "text/");
   var load = URL.loadString(urlstr, ctype);
   WMLBrowser.setVar("urlstring", urlstr);
   WMLBrowser.setVar("contenttype", ctype);
   WMLBrowser.setVar("loadstr", load);
   WMLBrowser.go("LoadStringExample.wml#card2");
};
Explanation:

Code for LoadStringExample.wmls

Language(s): WML

See Also: