View Full Version : how to use query string in laszlo
jamil05
10-03-2006, 04:05 AM
hi all,
Canm someone explain me how to use query string in laszlo?
i have to capture the parameters from a query string.how can i do it?
thx in advance for your help
jks_pdx
10-03-2006, 10:39 AM
For your conveneince, OpenLaszlo stuffs all the query strings into the canvas. So if your URL was
http://www...../test.lzx?user=dave&item=hat
Then you would find that there was an attribute of canvas named 'user' with value 'dave', and another one named 'item' with value 'hat'.
If you want to parse the query string youself, you can get it with a call to LzBrowser.getLoadURL();
jamil05
10-04-2006, 09:05 PM
hi,
How can i capture the value parsed as query string from the web address below?
http://www...../test.lzx?user=dave&item=hat
thx
jks_pdx
10-05-2006, 07:40 AM
Sorry about that. I forgot exactly how this worked, and obviously didn't test it.
If you lauched with the following URL:
http://www...../test.lzx?lzr=swf8&user=dave&item=hat
Then in your code you can do any of the following:
<canvas debug='true'>
<handler name='oninit'>
var lLoadURL;
var lQueryStr;
Debug.write(_root.user);
Debug.write(_root.item);
Debug.write(LzBrowser.getInitArg('user'));
Debug.write(LzBrowser.getInitArg('item'));
lLoadURL = LzBrowser.getLoadURL();
Debug.write(lLoadURL);
lQueryStr = lLoadURL.substr(lLoadURL.indexOf('?'));
Debug.write(lQueryStr);
if ($swf8)
{
lLoadURL = flash.external.ExternalInterface.call('eval','wind ow.location.toString()');
Debug.write(lLoadURL);
lQueryStr = lLoadURL.substr(lLoadURL.indexOf('?'));
Debug.write(lQueryStr);
}
</handler>
</canvas>
Note that LzBrowser.getLoadURL() doesn't actually seem to return the full query string. If you're building for flash 8, then you can use the flash access to the browser to get the real query string.
vBulletin® v3.8.4, Copyright ©2000-2012, Jelsoft Enterprises Ltd.