Browser::execute: Difference between revisions
MrPancakers (talk | contribs) m (Using old browser template) |
|||
| Line 9: | Line 9: | ||
==Example== | ==Example== | ||
That's example made nothing useful | That's example made nothing useful: | ||
<syntaxhighlight lang="javascript"> | <syntaxhighlight lang="javascript"> | ||
browser.execute(`alert(\`It's a test.\`);`); | browser.execute(`alert(\`It's a test.\`);`); | ||
</syntaxhighlight> | |||
Get Chatbox status by executing code / check if open: | |||
<syntaxhighlight lang="javascript"> | |||
var isChatOpen = toggle; | |||
mp.events.add('render', () => { | |||
if (mp.game.controls.isDisabledControlJustReleased(0, 245)) { | |||
if (isChatOpen) | |||
return; | |||
mp.gui.execute("const _enableChatInput = enableChatInput;enableChatInput = (enable) => { mp.trigger('chatEnabled', enable); _enableChatInput(enable) };"); | |||
} | |||
} | |||
</syntaxhighlight> | </syntaxhighlight> | ||
==See Also== | ==See Also== | ||
{{Browser_definition_c}} | {{Browser_definition_c}} | ||
Revision as of 17:10, 27 July 2018
This function used for call JavaScript code in created browser.
Syntax
browser.execute(String executedCode);
Required Arguments
- executedCode: JavaScript code what will be executed in browser.
Example
That's example made nothing useful:
browser.execute(`alert(\`It's a test.\`);`);
Get Chatbox status by executing code / check if open:
var isChatOpen = toggle;
mp.events.add('render', () => {
if (mp.game.controls.isDisabledControlJustReleased(0, 245)) {
if (isChatOpen)
return;
mp.gui.execute("const _enableChatInput = enableChatInput;enableChatInput = (enable) => { mp.trigger('chatEnabled', enable); _enableChatInput(enable) };");
}
}
See Also
- Functions:
- Properies: