how to get data from widget browser
Jacques Hausser
Jacques.Hausser at unil.ch
Wed May 25 11:13:21 EDT 2016
mmm… yes, I’ll try something in that direction (except that in the real case it will be a bit more complicated). A pity this beautiful widget has nothing more straightforward to pick data from webpages (but perhaps it has, well hidden).
Thank you anyway, Mike !
Jacques
> Le 25 mai 2016 à 16:03, Mike Bonner <bonnmike at gmail.com> a écrit :
>
> 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
>
>
> <html>
> <body>
> Hi!
> <script>
> function testit () {
> liveCode.myJSHandler("myMessage",12345);
> }
> </script>
> </body></html>
>
> 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
> expected.
>
> 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 unil.ch>
> wrote:
>
>> 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 lists.runrev.com
>> Please visit this url to subscribe, unsubscribe and manage your
>> subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
******************************************
Prof. Jacques Hausser
Department of Ecology and Evolution
Biophore / Sorge
University of Lausanne
CH 1015 Lausanne
please use my private address:
6 route de Burtigny
CH-1269 Bassins
tel: ++ 41 22 366 19 40
mobile: ++ 41 79 757 05 24
E-Mail: jacques.hausser at unil.ch
*******************************************
More information about the use-livecode
mailing list