SetBrowserProperty: Difference between revisions
Jump to navigation
Jump to search
(Added setBrowserProperty - https://github.com/multitheftauto/mtasa-blue/commit/4a89394d70cbb8dcf446c5be9d56608225c04b02) |
m (Link to the Romanian translation of this page added.) |
||
(8 intermediate revisions by 6 users not shown) | |||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
{{ | {{Client function}} | ||
{{New feature/item|3.0150|1.5|| | {{New feature/item|3.0150|1.5|| | ||
This function | This function sets a given property of a specified browser. | ||
}} | }} | ||
==Syntax== | ==Syntax== | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
bool setBrowserProperty ( string key, string value ) | bool setBrowserProperty ( browser theBrowser, string key, string value ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
{{OOP||[[Element/Browser|browser]]:setProperty|| | {{OOP||[[Element/Browser|browser]]:setProperty||getBrowserProperty}} | ||
===Required arguments=== | ===Required arguments=== | ||
*'''theBrowser:''' The browser element you want to set a property of | |||
*'''key:''' The browser property key. It can be: | *'''key:''' The browser property key. It can be: | ||
**'''mobile:''' Surfing the web as mobile | **'''mobile:''' Surfing the web as mobile | ||
*'''value:''' A value | *'''value:''' A value indicating whether to enable ("1") the property or not ("0") | ||
===Returns=== | ===Returns=== | ||
Returns ''true'' if the property was successfully | Returns ''true'' if the property was successfully set, ''false'' otherwise. | ||
==Example== | ==Example== | ||
This example will add a command handler for 'mobile' that will toggle mobile browsing for all browsers. | |||
<syntaxhighlight lang="lua"> | |||
== | addCommandHandler("mobile", | ||
function () | |||
for i, browser in pairs(getElementsByType("webbrowser")) do | |||
setBrowserProperty(browser, "mobile", getBrowserProperty(browser, "mobile") == "1" and "0" or "1") | |||
end | |||
end) | |||
</syntaxhighlight> | |||
==See also== | ==See also== | ||
{{CEF_functions}} | {{CEF_functions}} | ||
[[hu:setBrowserProperty]] | |||
[[RO:setBrowserProperty]] |
Latest revision as of 14:43, 8 April 2020
This function sets a given property of a specified browser.
Syntax
bool setBrowserProperty ( browser theBrowser, string key, string value )
OOP Syntax Help! I don't understand this!
- Method: browser:setProperty(...)
- Counterpart: getBrowserProperty
Required arguments
- theBrowser: The browser element you want to set a property of
- key: The browser property key. It can be:
- mobile: Surfing the web as mobile
- value: A value indicating whether to enable ("1") the property or not ("0")
Returns
Returns true if the property was successfully set, false otherwise.
Example
This example will add a command handler for 'mobile' that will toggle mobile browsing for all browsers.
addCommandHandler("mobile", function () for i, browser in pairs(getElementsByType("webbrowser")) do setBrowserProperty(browser, "mobile", getBrowserProperty(browser, "mobile") == "1" and "0" or "1") end 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