ExecuteBrowserJavascript: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
CrosRoad95 (talk | contribs) (removed vulnerability from example :) because i want to backdoor everyone) |
||
(4 intermediate revisions by 3 users not shown) | |||
Line 31: | Line 31: | ||
addEventHandler("onClientBrowserDocumentReady", browser, | addEventHandler("onClientBrowserDocumentReady", browser, | ||
function () | function () | ||
executeBrowserJavascript(source, "document.getElementById('nick'). | executeBrowserJavascript(source, string.format("document.getElementById('nick').innerText = %q;", getPlayerName(localPlayer))) | ||
end) | end) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Line 38: | Line 38: | ||
{{CEF_functions}} | {{CEF_functions}} | ||
[[hu: | [[hu:executeBrowserJavascript]] | ||
[[RO:executeBrowserJavascript]] |
Latest revision as of 19:16, 5 July 2024
This function executes a Javascript string to the specified browser. Works only with local browsers.
Syntax
bool executeBrowserJavascript ( browser webBrowser, string jsCode )
OOP Syntax Help! I don't understand this!
- Method: browser:executeJavascript(...)
Required Arguments
- webBrowser: The web browser which will execute the Javascript code
- jsCode: The Javascript code string
Returns
Returns true if executing Javascript is allowed in the current context, false otherwise.
Example
This example shows how to display the name (nick) of the local player on the webpage.
local browser = guiGetBrowser(guiCreateBrowser(200, 200, 400, 200, true, false, false)) addEventHandler("onClientBrowserCreated", browser, function () loadBrowserURL(source, "http://mta/local/example.html") --Containing <span id="nick"></span> somewhere in the file end) --The page has to load first addEventHandler("onClientBrowserDocumentReady", browser, function () executeBrowserJavascript(source, string.format("document.getElementById('nick').innerText = %q;", getPlayerName(localPlayer))) end)
See Also
- canBrowserNavigateBack
- canBrowserNavigateForward
- createBrowser
- executeBrowserJavascript
- focusBrowser
- getBrowserProperty
- getBrowserSettings
- getBrowserSource
- getBrowserTitle
- getBrowserURL
- injectBrowserMouseDown
- injectBrowserMouseMove
- injectBrowserMouseUp
- injectBrowserMouseWheel
- isBrowserDomainBlocked
- isBrowserFocused
- isBrowserLoading
- isBrowserRenderingPaused
- loadBrowserURL
- navigateBrowserBack
- navigateBrowserForward
- reloadBrowserPage
- requestBrowserDomains
- resizeBrowser
- setBrowserAjaxHandler
- setBrowserProperty
- setBrowserRenderingPaused
- setBrowserVolume
- toggleBrowserDevTools