Apache Cordova / Phonegap InAppBrowser is used for Loading Child Browser in your application (which cannot access cordova api like camera, contacts ..etc) for loading third party (untrusted) content. This provide some default UI controls such as back, forward, done.

Installing InAppBrowser Plugin

To use Apache Cordova / Phonegap InAppBrowser we need to add a plugin. you can add a plugin using these command

cordova plugin add cordova-plugin-inappbrowser

Working with InAppBrowser

var ref = cordova.InAppBrowser.open(url, target, options);

where

url – your target url. use encodeURI() for UniCode Characters

target

  • _self: Opens in the Cordova WebView if the URL is in the white list, otherwise it opens in the InAppBrowser.
  • _blank: Opens in the InAppBrowser.
  • _system: Opens in the system’s web browser.

options: Options for the InAppBrowser. Optional, defaulting to: location=yes

Apache Cordova / Phonegap InAppBrowser Example

var ref = cordova.InAppBrowser.open('https://codesundar.com', '_blank', 'location=yes');
(or)
var ref = window.open('https://codesundar.com', '_blank', 'location=yes');

How to Open Link in External Browser using Phonegap / Apache cordova ?

<a href="#" onclick="cordova.InAppBrowser.open('https://codesundar.com', '_system', 'location=yes');">Open Link in External</a>
(or)
<a href="#" onclick="window.open('https://codesundar.com', '_system', 'location=yes');">Open Link in External</a>

 

Realtime usage / example of Apache Cordova / Phonegap InApp Browser Plugin :

  • Payment Gateway Integration.
  • Use InAppBrowser instead of IFrame.
  • You can use InAppBrowser for Loading Untrusted third party Content
  • Know more ? please comment below

Supported Platforms :

  • Amazon Fire OS
  • Android
  • BlackBerry 10
  • Firefox OS
  • iOS
  • Windows 8 and 8.1
  • Windows Phone 7 and 8
  • Browser
Sundaravel M

About the author: Hey! It's me sundar. (Yea, I'm the founder of codesundar.com). I'm a passionate computer programmer who loves modern web and mobile development. feel free to reach me : Facebook - Twitter - Google+