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 wv = webview.create()

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

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

On this page