Page 1 of 1

do in widget (execute javascript in browser widget) - possible to get result?

Posted: Wed Oct 17, 2018 10:36 am
by rodneyt
Hi everyone,

The do in widget command allows one to execute a javascript in the browser widget. Is there any way to get a result back? The conventional "do" command has a result but it seems the widget variant doesn't? Seems like a major omission?

~ Rodney

Re: do in widget (execute javascript in browser widget) - possible to get result?

Posted: Wed Oct 17, 2018 11:11 pm
by rodneyt
OK so here's the correct way to do this:

on preopenstack
set the javascriptHandlers of widget "ob3" to "jscallback"
end preopenstack

on test
local tJS
put "var myLoc;"&return&"myLoc=window.location.href;"&return&"liveCode.jscallback('location', myLoc);" into tJS
do tJS in widget "ob3"
end test

on jscallback pMessage,pValue
put "jscallback:" && pMessage & ":" && pValue
end jscallback

Re: do in widget (execute javascript in browser widget) - possible to get result?

Posted: Thu Oct 18, 2018 7:56 am
by [-hh]
Hi. Welcome to the forum.

You don't have to "beautify" the javaScript. This would be enough:

Code: Select all

on test
   do "liveCode.jscallback('location',location.href)" in widget "ob3"
end test