ServersYour serverFor creatorsForumFAQDocumentationSecurity
Download the launcher
  1. Documentation
  2. Client functions
  3. evaluateBrowserJavascript

Function

evaluateBrowserJavascript

ClientBrowserTrilogy Hub only

Runs JavaScript on a local page and returns its result to Lua. If the code returns a Promise, the function waits for it.

Syntax

bool evaluateBrowserJavascript(browser webBrowser, string code, function callback)

Arguments

webBrowserbrowser
A local browser.
codestring
JavaScript code.
callbackfunction
A function(ok, result) callback: ok says whether it worked, result is the result or the error message.

Returns

true if the code was sent.

Example

evaluateBrowserJavascript(browser, "document.querySelectorAll('li').length", function(ok, count)
    if ok then
        outputChatBox("Na liście jest " .. count .. " pozycji")
    end
end)

See also