Webview:onMessage(msg)event
This event is fired when the Webview widget has received a message from the web page.
Parameters
msg
A string value representing the message received, encoded in JSON format.
Return value
The event returns no value.Example
--! luart-extensions
import ui
require "webview"
-- creates a simple window
local win = ui.Window("Webview:onResult() event sample", 320, 200)
local Webview = ui.Webview(win, 150, 70)
-- Don't show the Webview widget
Webview:hide()
-- Webview:onResult() event to center the Webview widget
function Webview:onResult(result)
ui.info(result, "Result of Math.PI in Javascript")
win:hide()
end
function Webview:onReady()
self:eval("Math.PI")
end
win:show()
-- update the ui
while win.visible do
ui.update()
end