GetBrowserProperty: Difference between revisions
Jump to navigation
Jump to search
m (Link to the Romanian translation of this page added.) |
No edit summary |
||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
{{Client function}} | {{Client function}} | ||
{{New feature/item|3.0150|1.5|| | {{New feature/item|3.0150|1.5|| | ||
This function gets a given property of a specified browser. | This function gets a given property of a specified browser. | ||
Line 21: | Line 20: | ||
==Example== | ==Example== | ||
<section name="Example" class="client" show="true"> | |||
This example creates a browser that displays (yotube.com) and a button to get the browser property: | |||
<syntaxhighlight lang="lua"> | |||
--[[ Example By MrKAREEM --]] | |||
gui = guiCreateWindow(422, 177, 535, 365, "youtube", false) | |||
guiWindowSetSizable(gui, false) | |||
propertyState = guiCreateButton(10, 332, 515, 23, "getBrowserProperty", false, gui) -- Create button to get your browser property | |||
webBrowser = guiCreateBrowser(9, 22, 516, 299, false, false, false, gui) -- Create a web browser, only works with local pages! | |||
local theBrowser = guiGetBrowser(webBrowser) -- Get the web browser | |||
-- Load our page on browser creation. | |||
addEventHandler("onClientBrowserCreated", theBrowser, function() | |||
showCursor(true) | |||
loadBrowserURL(source, "http://m.youtube.com\\") | |||
end | |||
) | |||
addEventHandler( "onClientGUIClick", resourceRoot, function ( ) | |||
if source == propertyState then | |||
if isBrowserLoading(theBrowser) then return outputChatBox('Please wait until the browser load!',255,0,0) end -- To avoid mistakes | |||
local getType = getBrowserProperty(theBrowser,'mobile') -- Getting the value of the browser property for the "mobile" key | |||
if getType == '0' then -- This checks whether or not the browser appears as a mobile page | |||
setBrowserProperty(theBrowser, "mobile", '1') -- Show the browser as a mobile page | |||
reloadBrowserPage(theBrowser) -- Reload the browser page | |||
guiSetText( gui, 'mobile_page' ) | |||
outputChatBox('You are viewing the browser as a mobile page') | |||
elseif getType == '1' then | |||
setBrowserProperty(theBrowser, "mobile", '0') -- Show the browser as a normal page | |||
reloadBrowserPage(theBrowser) -- Reload the browser page | |||
guiSetText( gui, 'web_page' ) | |||
outputChatBox('You are viewing the browser as a web page') | |||
end | |||
end | |||
end ) | |||
</syntaxhighlight> | |||
</section> | |||
==See also== | ==See also== |
Revision as of 16:39, 8 June 2020
This function gets a given property of a specified browser.
Syntax
bool getBrowserProperty ( browser theBrowser, string key )
OOP Syntax Help! I don't understand this!
- Method: browser:getProperty(...)
- Counterpart: setBrowserProperty
Required arguments
- theBrowser: browser element to get the property value of
- key: The browser property key. It can be:
- mobile: Surfing the web as mobile
Returns
Returns the value if the property was successfully found, false otherwise.
Example
Click to collapse [-]
ExampleThis example creates a browser that displays (yotube.com) and a button to get the browser property:
--[[ Example By MrKAREEM --]] gui = guiCreateWindow(422, 177, 535, 365, "youtube", false) guiWindowSetSizable(gui, false) propertyState = guiCreateButton(10, 332, 515, 23, "getBrowserProperty", false, gui) -- Create button to get your browser property webBrowser = guiCreateBrowser(9, 22, 516, 299, false, false, false, gui) -- Create a web browser, only works with local pages! local theBrowser = guiGetBrowser(webBrowser) -- Get the web browser -- Load our page on browser creation. addEventHandler("onClientBrowserCreated", theBrowser, function() showCursor(true) loadBrowserURL(source, "http://m.youtube.com\\") end ) addEventHandler( "onClientGUIClick", resourceRoot, function ( ) if source == propertyState then if isBrowserLoading(theBrowser) then return outputChatBox('Please wait until the browser load!',255,0,0) end -- To avoid mistakes local getType = getBrowserProperty(theBrowser,'mobile') -- Getting the value of the browser property for the "mobile" key if getType == '0' then -- This checks whether or not the browser appears as a mobile page setBrowserProperty(theBrowser, "mobile", '1') -- Show the browser as a mobile page reloadBrowserPage(theBrowser) -- Reload the browser page guiSetText( gui, 'mobile_page' ) outputChatBox('You are viewing the browser as a mobile page') elseif getType == '1' then setBrowserProperty(theBrowser, "mobile", '0') -- Show the browser as a normal page reloadBrowserPage(theBrowser) -- Reload the browser page guiSetText( gui, 'web_page' ) outputChatBox('You are viewing the browser as a web page') end end end )
See also
- canBrowserNavigateBack
- canBrowserNavigateForward
- createBrowser
- executeBrowserJavascript
- focusBrowser
- getBrowserProperty
- getBrowserSettings
- getBrowserSource
- getBrowserTitle
- getBrowserURL
- injectBrowserMouseDown
- injectBrowserMouseMove
- injectBrowserMouseUp
- injectBrowserMouseWheel
- isBrowserDomainBlocked
- isBrowserFocused
- isBrowserLoading
- isBrowserRenderingPaused
- loadBrowserURL
- navigateBrowserBack
- navigateBrowserForward
- reloadBrowserPage
- requestBrowserDomains
- resizeBrowser
- setBrowserAjaxHandler
- setBrowserProperty
- setBrowserRenderingPaused
- setBrowserVolume
- toggleBrowserDevTools