CanBrowserNavigateForward: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Added page for CanBrowserNavigateFroward)
 
mNo edit summary
Line 2: Line 2:
{{Client function}}
{{Client function}}
{{New feature/item|3.0153|1.5.3|9912|
{{New feature/item|3.0153|1.5.3|9912|
Checks if the browser can go to the next page.
This function checks if the browser can go to the next page.
}}
}}


Line 11: Line 11:


===Required Arguments===
===Required Arguments===
*'''webBrowser:''' The browser you want navigate forward.
*'''webBrowser:''' The browser you want check for a next page.


===Returns===
===Returns===
Returns ''true'' if the browser can navigate forward, ''false'' otherwise.
Returns ''true'' if the browser can go to the next page, ''false'' otherwise.


==Example==
==Example==

Revision as of 00:16, 18 December 2016

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, "Firechrome", false)
guiWindowSetSizable(window, false)

navigateBackBtn = guiCreateButton(10, 19, 39, 36, "<", false, window)
navigateForwardBtn = guiCreateButton(98, 19, 39, 36, ">", false, window)
addressBar =  guiCreateEdit(137, 19, 701, 36, "", false, window)
guiSetEnabled( addressBar, false )
reloadBtn = guiCreateButton(49, 19, 49, 36, "reload", false, window)
browser = guiCreateBrowser(10, 55, 828, 609, false, false, false, window)

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

-- This checks to see if the browser can navigate in any direction and enables the back or forward buttons
addEventHandler( "onClientBrowserDocumentReady", theBrowser, function( )
    navigateForwardBtn.enabled = (canBrowserNavigateForward(theBrowser))
    navigateBackBtn.enabled = (canBrowserNavigateBack(theBrowser))
    guiSetText( addressBar, getBrowserURL( theBrowser ) )
end )

-- This part handles the GUI navigation buttons for the browser.
addEventHandler( "onClientGUIClick", resourceRoot, function ( )
    if source == navigateBackBtn then
        navigateBrowserBack(theBrowser)
    elseif source == navigateForwardBtn then
        navigateBrowserForward(theBrowser)
    elseif source == reloadBtn then
        reloadBrowserPage(theBrowser)
    end
end )

See Also