how to get data from widget browser

Mike Bonner bonnmike at
Wed May 25 10:03:30 EDT 2016

Just experimented with things and found a way that works.  There is
probably a more direct way using do "script" in browser directly, but I
haven't figured that out yet.  In the interim..

I put this into the htmltext of a widget

function testit () {

It defines a function testit, that then defines an inline function using
the liveCode object, handler named myJSHandler

In my livecode script I have this

command setHandlers
   set the javascriptHandlers of widget 1 to "myJSHandler" -- tells the
widget that when the livecode.myJSHandler() function is able to execute the
myJSHandler handler in lc
end setHandlers

command myJSHandler pMessage,pVar
   put pMessage & cr & pVar -- A simple example with returned data
end myJSHandler

To see it in action, I executed in the message box..
do "testit()" in widget 1 -- my only widget
The function ran, called the livecode handler myJSHandler passing the 2
values in, and the livecode handler put them into the message box as

It should be possible to write a generic handler in lc to receive data,
then add it to the javascripthandlerlist for that widget.  You shouldn't
even have to pre-define your javascript as part of your htmltext, you
should be able to execute on the fly.

do "liveCode.myJSHandler('this is a message',8*8)"in widget 1

Which will call the livecode myJSHandler  from javascript in the widget
after evaluating the 8*8

On Wed, May 25, 2016 at 6:51 AM, Jacques Hausser <Jacques.Hausser at>

> Sorry to come back with this question. I have a widget browser defined by
> a html file. It works fine. But I’m trying to get the result returned by
> some functions in the html, that is, to find an equivalent of the
> revBrowserCallScript function, which was working well with the pre-8
> versions of my stack. I tried “do ‘script’ in widget” with several
> ‘scripts’, without success, I cannot find where the returned value is
> hidden (I must confess I’m a featherless sparrow rather than an eagle in
> javascript).
> Thank you in advance
> Jacques
> _______________________________________________
> use-livecode mailing list
> use-livecode at
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:

More information about the Use-livecode mailing list