Apache Cordova InAppBrowser Plugin
Apache Cordova InAppBrowser Plugin
) ) You can show helpful articles, videos, and web resources inside of your app. Users can view web pages without leaving your app.
To get a few ideas, check out the sample at the bottom of this page or go straight to the reference content.
This plugin provides a web browser view that displays when calling cordova.InAppBrowser.open().
var ref = cordova.InAppBrowser.open('https://apache.org', '_blank', 'location=yes');window.openThe cordova.InAppBrowser.open() function is defined to be a drop-in replacement
for the window.open() function. Existing window.open() calls can use the
InAppBrowser window, by replacing window.open:
window.open = cordova.InAppBrowser.open;If you change the browsers window.open function this way, it can have unintended side
effects (especially if this plugin is included only as a dependency of another
plugin).
The InAppBrowser window behaves like a standard web browser, and can't access Cordova APIs. For this reason, the InAppBrowser is recommended if you need to load third-party (untrusted) content, instead of loading that into the main Cordova webview. The InAppBrowser is not subject to the whitelist, nor is opening links in the system browser.
The InAppBrowser provides by default its own GUI controls for the user (back, forward, done).
cordova plugin add cordova-plugin-inappbrowserIf you want all page loads in your app to go through the InAppBrowser, you can
simply hook window.open during initialization. For example:
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
window.open = cordova.InAppBrowser.open;
}Opens a URL in a new InAppBrowser instance, the current browser
instance, or the system browser.
var ref = cordova.InAppBrowser.open(url, target, options);ref: Reference to the InAppBrowser window when the target is set to '_blank'. (InAppBrowser) On Android, non-whitelisted URLs also fall back to the InAppBrowser when the target is set to '_self'.
url: The URL to load (String). Call encodeURI() on this if the URL contains Unicode characters.
target: The target in which to load the URL, an optional parameter that defaults to _self. (String)
_self: Opens in the Cordova WebView. On Android, non-whitelisted URLs fall back to the InAppBrowser. On iOS, the current implementation does not perform this fallback and navigation remains in the Cordova WebView (subject to ``)._blank: Opens in the InAppBrowser._system: Opens in the system's web browser.options: Options for the InAppBrowser. Optional, defaulting to: location=yes. (String)
The options string must not contain any blank space, and each feature's name/value pairs must be separated by a comma. Feature names are case insensitive.
All platforms support:
yes or no to turn the InAppBrowser's location bar on or off.Android supports these additional options:
yes to create the browser and load the page, but not show it. The loadstop event fires when loading is complete. Omit or set to no (default) to have the browser open and load normally.beforeload event to modify which pages are actually loaded in the browser. Accepted values are get to intercept only GET requests, post to intercept on POST requests or yes to intercept both GET & POST requests. Note that POST requests are not currently supported and will be ignored (if you set beforeload=post it will raise an error).yes to clear the shared browser's cookie cache of your app, which means also the one of the Cordova WebView, before the in-app browser is opened.yes to clear the shared session cookies from the browser's cache of your app, which means also the one of the Cordova WebView, before the in-app browser is opened.#00ff00, and it will change the
close button color from default, regardless of being a text or default X. Only has effect if user has location set to yes.yes to show a close button in the footer similar to the iOS Done button.
The close button will appear the same as for the header hence use closebuttoncaption and closebuttoncolor to set its properties.#00ff00 or #CC00ff00 (#aarrggbb) , and it will change the footer color from default.
Only has effect if user has footer set to yes.yes to use the hardware back button to navigate backwards through the InAppBrowser's history. If there is no previous page, the InAppBrowser will close. The default value is yes, so you must set it to no if you want the back button to simply close the InAppBrowser.yes to hide the navigation buttons on the location toolbar, only has effect if user has location set to yes. The default value is no.yes to hide the url bar on the location toolbar, only has effect if user has location set to yes. The default value is no.#00ff00, and it will change the color of both navigation buttons from default. Only has effect if user has location set to yes and not hidenavigationbuttons set to yes.#00ff00, and it will change the color the toolbar from default. Only has effect if user has location set to yes.yes to swap positions of the navigation buttons and the close button. Specifically, navigation buttons go to the right and close button to the left. Default value is no.no to disable it. Default value is yes.yes to show Android browser's zoom controls, set to no to hide them. Default value is yes. The zoom controls are deprecated since Android API Level 26 (Android 8). Google recommends to disable them.yes to prevent HTML5 audio or video from autoplaying (defaults to no).yes to make InAppBrowser WebView to pause/resume with the app to stop background audio (this may be required to avoid Google Play issues like described in CB-11013).no, the layout width is always set to the width of the WebView control in device-independent (CSS) pixels. When the value is yes and the page contains the viewport meta tag, the value of the width specified in the tag is used. If the page does not contain the tag or does not provide a width, then a wide viewport will be used. (defaults to yes).yes.iOS supports these additional options:
yes to create the browser and load the page, but not show it. The loadstop event fires when loading is complete. Omit or set to no (default) to have the browser open and load normally.beforeload event to modify which pages are actually loaded in the browser. Accepted values are get to intercept only GET requests, post to intercept on POST requests or yes to intercept both GET & POST requests. Note that POST requests are not currently supported and will be ignored (if you set beforeload=post it will raise an error).yes to clear the browser's cookie cache of your app, which means also the one of the Cordova WebView, before the in-app browser is opened.yes to clear the shared session cookies from the browser's cache of your app, which means also the one of the Cordova WebView, before the in-app browser is opened.yes to clear the shared browser's entire local storage of your app, which means also the one of the Cordova WebView, like cookies, HTML5 local storage, IndexedDB, etc., before the in-app browser is opened.#00ff00, to change from the default Done button's color. Only applicable if toolbar is not disabled.yes or no (default is no). Turns on/off the the bounce of the WKWebView's UIScrollView.yes or no to turn the toolbar navigation buttons on or off (defaults to no). Only applicable if toolbar is not disabled.#00ff00, to change from the default color. Only applicable if navigation buttons are visible.yes or no to turn the toolbar on or off for the InAppBrowser (defaults to yes)#00ff00, to change from the default color of the toolbar. Only applicable if toolbar is not disabled.yes or no to make the toolbar translucent(semi-transparent). Only applicable if toolbar is not disabled. The toolbar is semi-transparent by default.yes to swap positions of the navigation buttons and the close button. Specifically, close button goes to the right and navigation buttons to the left.yes or no to prevent viewport scaling through a meta tag (defaults to no).yes to prevent HTML5 audio or video from autoplaying (defaults to no).yes or no to allow in-line HTML5 media playback, displaying within the browser window rather than a device-specific playback interface. The HTML's video element must also include the webkit-playsinline attribute (defaults to no).pagesheet, formsheet or fullscreen to set the presentation style (defaults to fullscreen).fliphorizontal, crossdissolve or coververtical to set the transition style (defaults to coververtical).top or bottom (default is bottom). Causes the toolbar to be atNo open issues yet, or sync has not completed.