LoadBrowserURL: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
mNo edit summary
No edit summary
Line 17: Line 17:


==Example==
==Example==
Todo
<syntaxhighlight lang="lua">
--In order to render the browser on the full screen, we need to know the dimensions.
local screenWidth, screenHeight = guiGetScreenSize()
 
--Let's create a new browser in local mode. We will not be able to load an external URL.
local webBrowser = createBrowser(screenWidth, screenHeight, true, false)
--This is the function to render the browser.
function webBrowserRender()
--Render the browser on the full size of the screen.
dxDrawImage(0, 0, screenWidth, screenHeight, webBrowser, 0, 0, 0, tocolor(255,255,255,255), true)
end
 
--The event onClientBrowserCreated will be triggered, after the browser has been initialized.
--After this event has been triggered, we will be able to load our URL and start drawing.
addEventHandler("onClientBrowserCreated", webBrowser,
function()
--After the browser has been initialized, we can load our file.
loadBrowserURL(webBrowser, "html/site.html")
--Now we can start to render the browser.
addEventHandler("onClientRender", root, webBrowserRender)
end
)
</syntaxhighlight>


==See also==
==See also==
{{CEF_functions}}
{{CEF_functions}}

Revision as of 06:49, 25 March 2015

This function loads the specified URL.

Syntax

bool loadBrowserURL ( browser webBrowser, string url )

OOP Syntax Help! I don't understand this!

Method: browser:loadURL(...)
Counterpart: loadBrowserURL


Required arguments

  • webBrowser: The browser element which will load the URL
  • url: The url you want to load. It can either contain a remote website ("http://" prefix) or a website stored within a local resource ("gui.html" for example).

Returns

Returns true if the URL was successfully loaded.

Example

--In order to render the browser on the full screen, we need to know the dimensions.
local screenWidth, screenHeight = guiGetScreenSize()

--Let's create a new browser in local mode. We will not be able to load an external URL.
local webBrowser = createBrowser(screenWidth, screenHeight, true, false)
	
--This is the function to render the browser.
function webBrowserRender()
	--Render the browser on the full size of the screen.
	dxDrawImage(0, 0, screenWidth, screenHeight, webBrowser, 0, 0, 0, tocolor(255,255,255,255), true)
end

--The event onClientBrowserCreated will be triggered, after the browser has been initialized.
--After this event has been triggered, we will be able to load our URL and start drawing.
addEventHandler("onClientBrowserCreated", webBrowser, 
	function()
		--After the browser has been initialized, we can load our file.
		loadBrowserURL(webBrowser, "html/site.html")
		--Now we can start to render the browser.
		addEventHandler("onClientRender", root, webBrowserRender)
	end
)

See also