ExecuteWebJS

From Onset Developer Wiki
ExecuteWebJS

Type: Function
Context: Client
Introduced: v1.0

Description

Executes Javascript in the WebUI. (Make sure to first call this after all your js is loaded by sending an event from js.)

Wait until OnWebLoadComplete was called.

Syntax

ExecuteWebJS(web, Javascript)

Parameters

  • web
    The web identifier.
  • Javascript
    The Javascript source.

Return Value

  • This function returns true if the web identifier is found. It does not return the return values from JS as this whole process is asynchronous.

Example

Example from the debug package: https://github.com/BlueMountainsIO/OnsetLuaScripts/blob/master/debug/debug_c.lua

function UpdateLocalInfo()
	local x, y, z = GetPlayerLocation()
	local h = GetPlayerHeading()

	local data = "<br>LOCAL (ID: " .. GetLocalPlayer() .. ")<br>"
	data = data .. "Loc: " .. x .. ", " .. y .. ", " .. z .. ", " .. h .. "<br>"
	data = data .. "Movement: " .. GetPlayerMovementMode() .. ", " .. GetPlayerMovementSpeed() .. "<br>"

	ExecuteWebJS(webui, "SetLocalInfo('"..data.."');")
end

See also