HU/executeBrowserJavascript: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Created page with "__NOTOC__ {{Client function}} {{New feature/item|3.0150|1.5|| This function executes a Javascript string to the specified browser. Works only with local br...")
 
No edit summary
Line 1: Line 1:
__NOTOC__
__NOTOC__
{{Client function}}
{{Client function hu}}
{{New feature/item|3.0150|1.5||
{{New feature/item|3.0150|1.5||
This function executes a Javascript string to the specified [[Element/Browser|browser]]. Works only with local browsers.
This function executes a Javascript string to the specified [[Element/Browser|browser]]. Works only with local browsers.
}}
}}


==Syntax==
==Szintaxis==
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
bool executeBrowserJavascript ( browser webBrowser, string jsCode )
bool executeBrowserJavascript ( browser webBrowser, string jsCode )
Line 11: Line 11:
{{OOP||[[Element/Browser|browser]]:executeJavascript}}
{{OOP||[[Element/Browser|browser]]:executeJavascript}}


===Required Arguments===
===Kötelező argumentumok===
*'''webBrowser:''' The web browser which will execute the Javascript code
*'''webBrowser:''' The web browser which will execute the Javascript code
*'''jsCode:''' The Javascript code string
*'''jsCode:''' The Javascript code string


===Returns===
===Visszaadott érték===
Returns ''true'' if executing Javascript is allowed in the current context, ''false'' otherwise.
Returns ''true'' if executing Javascript is allowed in the current context, ''false'' otherwise.


==Example==
==Példa==
This example shows how to display the name (nick) of the local player on the webpage.
This example shows how to display the name (nick) of the local player on the webpage.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
Line 35: Line 35:
</syntaxhighlight>
</syntaxhighlight>


==See Also==
==SLásd még==
{{CEF_functions}}
{{CEF_functions}}


[[en:executeBrowserJavascript]]
[[en:executeBrowserJavascript]]
==Fordította==
* Surge

Revision as of 11:02, 30 July 2018

This function executes a Javascript string to the specified browser. Works only with local browsers.

Szintaxis

bool executeBrowserJavascript ( browser webBrowser, string jsCode )

OOP Syntax Help! I don't understand this!

Method: browser:executeJavascript(...)


Kötelező argumentumok

  • webBrowser: The web browser which will execute the Javascript code
  • jsCode: The Javascript code string

Visszaadott érték

Returns true if executing Javascript is allowed in the current context, false otherwise.

Példa

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, "document.getElementById('nick').innerHTML = '" .. getPlayerName(localPlayer) .. "'");
    end)

SLásd még

Fordította

  • Surge