[Cordova Inappbrowser Open browser within app]

Source: Internet
Author: User

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]

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.