DedrisFrameworkDedrisFramework

← Plugins  /  In-App Browser

🌐

In-App Browser

cordova-plugin-inappbrowser
iOS Android 🌐 Browser

This official Apache Cordova plugin opens a URL inside a separate, controllable web view that sits on top of your app — without leaving it. You get back a browser instance you can listen to, run scripts in, and close programmatically, which makes it ideal for OAuth flows, help pages and external links.

Installation

Add the plugin to your Cordova project from the command line:

terminal
cordova plugin add cordova-plugin-inappbrowser

Opening a window

Call cordova.InAppBrowser.open() after deviceready. It returns an InAppBrowser instance:

SignatureDescription
cordova.InAppBrowser.open(url, target, options)Opens url and returns a reference to the new browser window.

The target argument decides where the URL loads:

TargetOpens in
_selfThe Cordova web view if the URL is in the allow list, otherwise the in-app browser.
_blankThe in-app browser (the default for most use cases).
_systemThe device's default system browser.

The options argument is a comma-separated string of feature=value pairs, e.g. location=yes,toolbar=yes,hidden=no. Common options include location, toolbar, hidden, zoom (Android) and presentationstyle (iOS).

Instance methods & events

MemberDescription
ref.close()Close the browser window.
ref.show() / ref.hide()Show or hide a window that was opened with hidden=yes.
ref.executeScript(details, cb)Run JavaScript inside the loaded page.
ref.insertCSS(details, cb)Inject CSS into the loaded page.
ref.addEventListener(event, cb)Listen for loadstart, loadstop, loaderror, message or exit.
ref.removeEventListener(event, cb)Stop listening for an event.

Usage example

Open a page, react when it finishes loading, and close it from code:

www/js/app.js
function openHelp() {
  var ref = cordova.InAppBrowser.open(
    "https://dedrisframework.com/docs.html",
    "_blank",
    "location=yes,toolbar=yes"
  );

  ref.addEventListener("loadstop", function () {
    console.log("Page loaded");
  });

  ref.addEventListener("exit", function () {
    console.log("Browser closed");
  });
}

Tips

📚 Source: the technical reference on this page (the method, targets, options and events) is based on the official Apache Cordova InAppBrowser documentation. Descriptions and examples have been rewritten in DedrisFramework's own words. Apache Cordova documentation is published by the Apache Software Foundation under the Apache License 2.0.
← Back to plugins Start a project