CanBrowserNavigateForward

From Multi Theft Auto: Wiki
Jump to navigation Jump to search

This function checks if the browser can go to the next page.

Syntax

bool canBrowserNavigateForward( browser webBrowser )

Required Arguments

  • webBrowser: The browser you want check for a next page.

Returns

Returns true if the browser can go to the next page, false otherwise.

Example

Click to collapse [-]
Client

This example creates a browser that can return to the last and previous pages and can also be refreshed:

window = guiCreateWindow(126, 122, 848, 674, "browser", false)
guiWindowSetSizable(window, false)
navigateBackBtn = guiCreateButton(10, 19, 39, 36, "<", false, window)
navigateForwardBtn = guiCreateButton(98, 19, 39, 36, ">", false, window)
reloadBtn = guiCreateButton(49, 19, 49, 36, "reload", false, window)
addressBar =  guiCreateEdit(137, 19, 701, 36, "", false, window)
guiSetEnabled(addressBar,false)
webBrowser = guiCreateBrowser(10, 55, 828, 609, false, false, false, window)
local theBrowser = guiGetBrowser(webBrowser) 

-- Load our page on browser creation.
addEventHandler("onClientBrowserCreated", theBrowser, 
    function()
	showCursor(true)
        loadBrowserURL(source, "https://forum.mtasa.com/")
    end
)


addEventHandler( "onClientBrowserDocumentReady", theBrowser, function( url )
guiSetText( addressBar, getBrowserURL( theBrowser ) )
end )

-- This part handles the GUI navigation buttons for the browser.
addEventHandler( "onClientGUIClick", resourceRoot, function ( )
    if source == navigateBackBtn then
	if canBrowserNavigateBack(theBrowser) ~= true then return end -- This checks to see if the browser can navigate to the back
        navigateBrowserBack(theBrowser)
    elseif source == navigateForwardBtn then -- This checks to see if the browser can navigate to the forward
	if canBrowserNavigateForward(theBrowser) ~= true then return end
        navigateBrowserForward(theBrowser)
    elseif source == reloadBtn then
        reloadBrowserPage(theBrowser)
    end
end )

See Also