Vital.sandbox
Webview

self:eval

Client

Evaluates a JavaScript expression inside the webview


Syntax

local status = self:eval(input)

Parameters

TypeNameDescription
stringinputJavaScript code to evaluate inside the webview

Returns

TypeNameDescription
boolstatustrue on successful execution, or false on failure

Examples

Evaluate JavaScript expressions inside a webview
local browser = webview.create()

--Change the page background color
browser:eval("document.body.style.background = 'red'")

--Post a message back to Lua
browser:eval("window.ipc.postMessage('hello from JS')")

On this page