GetBrowserSource: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
mNo edit summary
m (fix syntax)
Line 1: Line 1:
__NOTOC__
__NOTOC__
{{Client function}}
{{Client function}}{{Needs Checking|example is probably broken}}
{{New feature/item|3.0151|1.5.1|7392|
{{New feature/item|3.0151|1.5.1|7392|
This function can be used to retrieve the source code of a website (asynchronously). The size of the source code is limited to 2 MiB (remaining bytes are cut).
This function can be used to retrieve the source code of a website (asynchronously). The size of the source code is limited to 2 MiB (remaining bytes are cut).
Line 7: Line 7:
==Syntax==
==Syntax==
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
table getBrowserSource ( function callback )
table getBrowserSource ( browser webBrowser, function callback )
</syntaxhighlight>
</syntaxhighlight>
{{OOP||[[Element/Browser|browser]]:getSource}}
===Required arguments===
*'''webBrowser:''' The browser element you want to get the source of
*'''callback:''' a callback function with syntax as described below
====Callback syntax====
====Callback syntax====
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
function ( string code )
function ( string code )
</syntaxhighlight>
</syntaxhighlight>
{{OOP||[[Element/Browser|Browser]].getSource}}


==Returns==
==Returns==
Line 23: Line 26:


-- Assuming a website has already been loaded
-- Assuming a website has already been loaded
getBrowserSource(function(code)
getBrowserSource(browser, function(code)
     -- Output code
     -- Output code
     outputChatBox(code)
     outputChatBox(code)

Revision as of 15:52, 2 January 2016

Dialog-information.png This article needs checking.

Reason(s): example is probably broken

This function can be used to retrieve the source code of a website (asynchronously). The size of the source code is limited to 2 MiB (remaining bytes are cut).

Syntax

table getBrowserSource ( browser webBrowser, function callback )

OOP Syntax Help! I don't understand this!

Method: browser:getSource(...)


Required arguments

  • webBrowser: The browser element you want to get the source of
  • callback: a callback function with syntax as described below

Callback syntax

function ( string code )

Returns

Returns true if valid arguments have been passed, false otherwise.

Example

local browser = createBrowser(...)

-- Assuming a website has already been loaded
getBrowserSource(browser, function(code)
    -- Output code
    outputChatBox(code)
end)

See Also