In this post, you will learn about the cordova-plugin-inappbrowser which provides a web view to display in your application.
Installing the plugin:
cordova plugin add cordova-plugin-inappbrowser
Initializing plugin:
When cordova.InAppBrowser.open() method is called, it display a web view.
var ref = cordova.InAppBrowser.open('http://apache.org', '_blank', 'location=yes');
You can use inappbrowser window if you want to load third party content, because inappbrowser window does not allow to use cordova API. It provides its by default GUI to control.
cordova.InAppBrowser.open:
It opens a URL in a new InAppBrowser instance or system browser.
var ref = cordova.InAppBrowser.open(url, target, options);
- ref: It refers to the InAppBrowser window.
- url: It is URL that you want to load. If the URL has unicode characters, you can call encodeURI().
- target: It is the target in which you want to open the URL. It is by default _self.
There are three parameters for target:
- _self: It opens in the cordova webview if the URL in whitelist otherwise opens in inappbrowser.
- _blank: It opens in the inappbrowser.
- _system: It opens in the browser window of device.
4. options: It is optional parameter and by default to location=yes. It is basically to turn the location of inappbrowser on or off.
0 Comment(s)