RequestBrowserDomains: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
m (Link to the Romanian translation of this page added.)
 
(14 intermediate revisions by 9 users not shown)
Line 1: Line 1:
__NOTOC__
__NOTOC__
{{Client_function}}
{{Client function}}
{{New feature/item|3.0150|1.5||
{{New feature/item|3.0150|1.5||
This function opens a request window in order to accept the requested remote URLs.
This function opens a request window in order to accept the requested remote URLs.
{{Note|You must use this function prior to calling [[loadBrowserURL]] because every domain, with exceptions in the whitelist [https://github.com/multitheftauto/mtasa-blue/blob/505467ec8c3ac1b3ad17fb0247dc15809e013968/Client/cefweb/CWebCore.cpp#L280-L283 here] and [https://github.com/multitheftauto/mtasa-blue/blob/505467ec8c3ac1b3ad17fb0247dc15809e013968/Client/cefweb/CWebCore.cpp#L205-L206 there], is blocked by default.}}
}}
}}


==Syntax==
==Syntax==
<syntaxhighlight lang="lua">bool requestBrowserDomains ( table pages [, bool parseAsURL = false] )</syntaxhighlight>
<syntaxhighlight lang="lua">bool requestBrowserDomains ( table pages [, bool parseAsURL = false, function callback ] )</syntaxhighlight>
{{OOP||[[Element/Browser|browser]].requestDomains||requestBrowserDomains}}
{{OOP||[[Element/Browser|Browser]].requestDomains}}


===Required Arguments===
===Required Arguments===
*'''pages:''' A table containing all domains ('''without''' <font color='red'><nowiki>http://</nowiki></font>)
*'''pages:''' A table containing all domains


===Optional Arguments===
===Optional Arguments===
*'''parseAsURL:''' ''true'' if the passed addresses should be converted from URLs, ''false'' otherwise.
*'''parseAsURL:''' ''true'' if the passed addresses should be converted from URLs, ''false'' otherwise.
*'''callback:''' A callback function that is called as soon as the result is available
Syntax:
<syntaxhighlight lang="lua">function(bool wasAccepted, table new_domains)</syntaxhighlight>


===Returns===
===Returns===
Line 22: Line 26:
showCursor(true) -- show cursor
showCursor(true) -- show cursor
addEventHandler("onClientBrowserWhitelistChange", root,
addEventHandler("onClientBrowserWhitelistChange", root,
function(newDomains)
  function(newDomains)
if newDomains[1] == "mtasa.com" then
    if newDomains[1] == "mtasa.com" then
local browser = createBrowser(1280, 720, false, false) -- create browser
      local browser = createBrowser(1280, 720, false, false) -- create browser
loadBrowserURL(browser, "http://mtasa.com/") -- load browser url
      loadBrowserURL(browser, "http://mtasa.com/") -- load browser url
end
  end
end
end
)
)
</syntaxhighlight>
</syntaxhighlight>
Line 33: Line 37:
==See also==
==See also==
{{CEF_functions}}
{{CEF_functions}}
[[hu:requestBrowserDomains]]
[[RO:requestBrowserDomains]]

Latest revision as of 14:22, 8 April 2020

This function opens a request window in order to accept the requested remote URLs.

[[{{{image}}}|link=|]] Note: You must use this function prior to calling loadBrowserURL because every domain, with exceptions in the whitelist here and there, is blocked by default.

Syntax

bool requestBrowserDomains ( table pages [, bool parseAsURL = false, function callback ] )

OOP Syntax Help! I don't understand this!

Method: Browser.requestDomains(...)


Required Arguments

  • pages: A table containing all domains

Optional Arguments

  • parseAsURL: true if the passed addresses should be converted from URLs, false otherwise.
  • callback: A callback function that is called as soon as the result is available

Syntax:

function(bool wasAccepted, table new_domains)

Returns

Returns true, if the string was successfully read, false otherwise.

Example

requestBrowserDomains({ "mtasa.com" }) -- request browser domain
showCursor(true) -- show cursor
addEventHandler("onClientBrowserWhitelistChange", root,
   function(newDomains)
     if newDomains[1] == "mtasa.com" then
       local browser = createBrowser(1280, 720, false, false) -- create browser
       loadBrowserURL(browser, "http://mtasa.com/") -- load browser url
   end
end
)

See also