FUNCTION:  URL.loadString

URL.loadString(url, contentType)
 
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.
 
The mandatory url parameter is the absolute URL of the target site.
 
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.
 
Code for LoadStringExample.wml
<?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>

 
Code for LoadStringExample.wmls
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");
};


Copyright 1999-2001 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information