How to obtain info from browser in revWeb app

Kee Nethery kee at kagi.com
Fri Jun 3 19:08:06 CDT 2011


The default web page for a revWeb app has this javascript in it (plus what I added):

<script type="text/javascript">
var urlParams = window.location.search.substring(1);  <!-- I added this line to the HTML generated by revWeb to get the CGI parameters -->
var agt=navigator.userAgent.toLowerCase();
var ie  = (agt.indexOf("msie") != -1);
var ns  = (navigator.appName.indexOf("Netscape") != -1);
var win = ((agt.indexOf("win")!=-1) || (agt.indexOf("32bit")!=-1));
var mac = (agt.indexOf("mac")!=-1);
... snip

In my stack I created a button with this script:

on mouseUp	
   do "result = urlParams" in browser
   put result() into theUrlParams
   answer theUrlParams with "OK"

   do "result = agt" in browser
   put result() into theAgent
   answer theAgent with "OK"
end mouseUp

When I call the revWeb page as though it is a CGI with these parameters added to the link:

test.html?firstclue=bonnmike&secondclue=andre

The first answer dialog displays:

firstclue=bonnmike&secondclue=andre

and then the second displays:

mozilla/5.0 (macintosh; intel mac os x 10.6; rv:2.0.1) gecko/20100101 firefox/4.0.1

The example Andre pointed to does all sorts of decoding of the parameters using javascript but we can do the decoding in livecode so I just grab the urlParams.

Thank you to Mike and Andre. 

Kee


More information about the use-livecode mailing list