ExecuteWebJS: Difference between revisions
From Onset Developer Wiki
X7airworker (talk | contribs) No edit summary |
No edit summary |
||
(2 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
{{Info|Function|Client|1.0}} | {{Info|Function|Client|1.0}} | ||
{{FuncDescription|Executes Javascript in the WebUI.}} | {{FuncDescription|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.}} | |||
{{FuncSyntax|ExecuteWebJS(web, Javascript)}} | {{FuncSyntax|ExecuteWebJS(web, Javascript)}} | ||
Line 9: | Line 11: | ||
{{FuncParam|Javascript|The Javascript source.}} | {{FuncParam|Javascript|The Javascript source.}} | ||
{{FuncReturnValue| | {{FuncReturnValue|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 == | ||
Example from the debug package: https://github.com/BlueMountainsIO/OnsetLuaScripts/blob/master/debug/debug_c.lua | |||
<syntaxhighlight lang="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 | |||
</syntaxhighlight> | |||
{{RelatedFunctions}} | {{RelatedFunctions}} | ||
{{WebEvents}} |
Latest revision as of 20:33, 30 August 2020
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