Scenario 1:
Using the Cordova plugin cordova-plugin-inappbrowser
1. Add Plugins
Cordova Plugin Add Cordova-plugin-inappbrowser
2. Invocation and Parameters
Cordova. Inappbrowser.open (URL, target, options), or window.open = Cordova. Inappbrowser.open;window.open (URL, target, options);
URL: If a Unicode character is included, call encodeURI (URL);
Target includes: _self, url Open in Cordova WebView in whitelist or open in Inappbrowser
_blank, open in Inappbrowser
_system, open in the system browser, such as Chrome/safari
Options include: "location =yes/no" Address bar
"Hidden=yes/no" No is the default, yes is normal load but not displayed by calling. Show (). Close () to display or close, as follows
Please refer to the website for other options.
var target = "_blank"; var options = "Location=yes,hidden=yes"; inappbrowserref = Cordova. Inappbrowser.open (URL, target, options); Inappbrowserref.addeventlistener (' Loadstart ', loadstartcallback); Inappbrowserref.addeventlistener (' Loadstop ', loadstopcallback); Inappbrowserref.addeventlistener (' Loaderror ', loaderrorcallback); ... function loadstopcallback () {if (inappbrowserref! = undefined) {inappbrowserref.show (); } } ...
Scenario 2:
Using the Cordova plugin Cordova-plugin-safariviewcontroller
1. Add Plugins
$ ionic Cordova Plugin Add cordova-plugin-safariviewcontroller$ npm install--save @ionic-native/safari-view-controller
2. Invocation and Parameters
...
if (typeof Safariviewcontroller!== ' undefined ') { safariviewcontroller.isavailable (function (available) { Console.log ("is available"); if (available) { Console.log ("Safari is available"); Safariviewcontroller.show ({ url:encodeuri (URL), toolbarcolor: ' #0091ea ', tintcolor: ' #0091ea ', controltintcolor: "#0091ea" }); } else { window.open (encodeURI (URL), ' _blank ', ' location=no ');}} ); } else { window.open ( encodeURI (URL), ' _blank ', ' location=no '); }
[Cordova Inappbrowser Open browser within app]