Enables the creation of a basic browser application.
Tabs for the browser are represented by WebViews.
Methods
-
addTab(success, failure, optionsopt) → {String}
-
Create a new tab. A tab represents a WebView.Parameters:
Name Type Attributes Description success
function The function to call when the tab is created successfully. failure
function The function to call when there is a error creating a tab. options
Object <optional>
The settings used to configure a WebView. Returns:
The identifier for the new WebView.- Type
- String
Example
//Define callback functions. function success(tabId) { console.log("Tab: ", tabId, " was created "); } function failure(e) { console.error("There was an error creating a tab: ", e); } qnx.browser.addTab(success, failure);
-
cancelWatch(watchId)
-
Stop monitoring the tab for changes. A tab represents a WebView.Parameters:
Name Type Description watchId
Number The watch ID returned by qnx.browser.watchTab()
.Example
qnx.browser.cancelWatch(watchId);
-
getActiveTab(success, failure) → {String}
-
Get the active tab. The active tab is the identifier of the WebView.Parameters:
Name Type Description success
function The function to call with the identifier of the active WebView. failure
function The function to call when there is a error getting the identifier of the active WebView. Returns:
The identifier of the active WebView.- Type
- String
Example
//Define callback functions. function success(tabId) { console.log("Tab: ", tabId, " is the active tab "); } function failure(e) { console.error("There was an error getting the active tab: ", e); } qnx.browser.getActiveTab(success, failure);
-
hideOverlay(success, failure)
-
Hide the overlay.Parameters:
Name Type Description success
function The function to call when the overlay is hidden. failure
function The function to call if there's an error hiding the overlay. Example
//Define callback functions. function success() { console.log("Overlay hidden"); } function failure(e) { console.error("There was an error hiding the overlay: ", e); } qnx.browser.hideOverlay(success, failure);
-
init(chromeUrl, uiHeight, overlayHeight)
-
Initialize the browser plugin.Parameters:
Name Type Description chromeUrl
String The URL of the WebView that handles all the user interface and application logic. uiHeight
Number The height you want your WebView to be when the overlay is hidden. overlayHeight
Number The height you want for your WebView to be when the overlay is visible. Example
var chromeUrl = "local:///index.html", uiHeight = 50, overlayHeight = 50; qnx.browser.init(chromeUrl, uiHeight, overlayHeight);
-
reload(success, failure)
-
Reload the active tab. The active tab represents the active WebView.Parameters:
Name Type Description success
function The function to call when reload succeeds. failure
function The function to call when there is a error reloading the WebView. Example
//Define callback functions. function success() { console.log("Tab was successfully reloaded"); } function failure(e) { console.error("There was an error reloading the tab: ", e); } qnx.browser.reload(success, failure);
-
removeTab(success, failure) → {String}
-
Remove a created tab. A tab is represents a WebView.Parameters:
Name Type Description success
function The function to call the tab is successfully removed. failure
function The function to call when there's an error removing a tab. Returns:
tabId The identifier of the tab that was removed.- Type
- String
Example
//Define callback functions. function success(tabId) { console.log("Tab: ", tabId, " was removed"); } function failure(e) { console.error("There was an error removing a tab: ", e); } qnx.browser.removeTab(success, failure, 5);
-
setActiveTab(success, failure) → {String}
-
Set the active tab using the identifier. The active tab represents the active WebView.Parameters:
Name Type Description success
function The function to call with the active WebView identifier. failure
function The function to call when there is a error setting the WebView identifier. Returns:
tabId The identifier of the active WebView.- Type
- String
Example
//Define callback functions. function success(tabId) { console.log("Tab: ", tabId, " is now the active tab "); } function failure(e) { console.error("There was an error setting the active tab: ", e); } qnx.browser.setActiveTab(success, failure, 5);
-
setDefaultTabParameters(success, fail, x, y, url)
-
Set the default parameters to apply to a tab when it's created. A tab represents a WebView.Parameters:
Name Type Description success
function The function to call when setDefaultTabParameters
successfully completes.fail
function The function to call when setDefaultTabParameters
doesn't successfully completes.x
Number The x-axis location for the top-left corner of the WebView. y
Number The y-axis location for the top-left corner of the WebView. url
String The default URL to load. Example
//Define callback functions. function success() { console.log("Default paramters successfully set"); } function failure(e) { console.error("Failed to set default WebView parameters", e); } qnx.browser.setDefaultTabParameters(success, failure, 0, 0, 800, 400, "www.qnx.com");
-
showOverlay(success, failure)
-
Show the overlay. The the overlay is shown, it's made visible to the user.Parameters:
Name Type Description success
function The function to call when the overlay is shown. failure
function The function to call if there is an error showing the overlay. Example
//Define callback functions. function success() { console.log("Overlay shown"); } function failure(e) { console.error("There was an error showing the overlay: ", e); } qnx.browser.showOverlay(success, failure);
-
stop(success, failure)
-
Stop the active tab from loading. The active tab represents the active WebView.Parameters:
Name Type Description success
function The function to call when the stop command succeeds. failure
function The function to call when there is a error stopping the WebView. Example
//Define callback functions. function success(tabId) { console.log("The tab was successfully reloaded"); } function failure(e) { console.error("There was an error reloading the tab: ", e); } qnx.browser.stop(success, failure);
-
updateUrl(success, failure) → {String}
-
Update the URL of the currently active tab. The active tab represents the active WebView.Parameters:
Name Type Description success
function The function to call with the updated URL. failure
function The function to call when there is a error setting the URL. Returns:
url The new URL for the active WebView.- Type
- String
Example
//Define callback functions. function success(url) { console.log("The url of the active tabs is now:",url); } function failure(e) { console.error("There was an error updating the url: ", e); } qnx.browser.updateUrl(success, failure, "www.qnx.com");
-
watchTab(callback) → {String}
-
Watch for updates to a tab. A tab represents a WebView.The following events cause an update:
- LocationChange: The URL in the WebView changed.
- PropertyLoadProgressEvent: New properties are being loaded into the WebView.
Parameters:
Name Type Description callback
function The function to call when a change is detected. Returns:
The identifier for the callback that was added.- Type
- String
Example
//Define a callback function. function myCallback(tabUpdates) { //Iterate through the changed items. for (var i=0; i<tabUpdates.length; i++) { //Currently updates related to "LocationChange" and "PropertyLoadProgressEvent". console.log("tab updates: " + tabUpdates[i] + '\n') } } var watchId = qnx.browser.watchTab(myCallback);
-
(inner) onUpdate(data)
-
Handles update events for this plugin.Parameters:
Name Type Description data
Array The updated data provided by the event.