getBrowserSource | Multi Theft Auto: Wiki Skip to content

getBrowserSource

Client-side
Server-side
Shared

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).

OOP Syntax Help! I don't understand this!

Syntax

bool getBrowserSource ( browser webBrowser, function callback ( code ) )
Required Arguments
  • webBrowser: The browser element you want to get the source of.
  • callback ( code ): A callback function with syntax function (string code).

Returns

  • bool: result

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

Code Examples

client
local browser = createBrowser(1024,1024,false,false) --Create Browser
addEventHandler("onClientBrowserCreated",browser,function()
loadBrowserURL(browser,"http://www.youtube.com") --Load URL
end)
addEventHandler("onClientBrowserDocumentReady",browser,function(url)
local rnt = getBrowserSource(browser,function(code) --Get Browser Source and Call Function
outputChatBox(code) --Output Code
end)
if rnt then
outputChatBox("Browser Source Got",0,255,0)
else
outputChatBox("Failed To Get Browser Source",255,0,0)
end
end)