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
do in widget (execute javascript in browser widget) - possible to get result?
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Re: do in widget (execute javascript in browser widget) - possible to get result?
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
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
-
- VIP Livecode Opensource Backer
- Posts: 2262
- Joined: Thu Feb 28, 2013 11:52 pm
- Location: Göttingen, DE
Re: do in widget (execute javascript in browser widget) - possible to get result?
Hi. Welcome to the forum.
You don't have to "beautify" the javaScript. This would be enough:
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
shiftLock happens