Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Cordova plugin InAppBrowser

    • 0
    • 0
    • 0
    • 0
    • 1
    • 0
    • 0
    • 0
    • 785
    Comment on it

    Hi All,
    Today we will discuss in this blog how to use InAppBrowser in your Cordova Application.

    -InAppBrowser is a web browser view in a Cordova application that displays when calling window.open() function.
    To use the functionality in your Cordova application first we need to install its plugin through CLI.

    cordova plugin add cordova-plugin-inappbrowser
    

    To open a URL in InAppBrowser, For example-
    var ref = window.open(url, target, options);

    ref:Reference to inappbrowser window.

    target:The target is used to load the URL.It is an optional parameter.
    Which are as follows-
    1._self: Opens a Cordova WebView, if the url is in the white list,otherwise it opens in the inappbrowser.
    2._blank: Opens Cordova WebView in InAppBrowser.
    3._system:Opens Cordova WebView in systems web browser.

    Option:It is an optional parameter and for Android devices and iOS devices these parameter can be different.
    To Know more about option parameters please go through below link:
    https://github.com/apache/cordova-plugin-inappbrowser

    We can add a listener for an event from InAppBrowser.Some Event Listeners are as follows:
    loadstart:The event fires when the InAppBrowser starts to load a URL.
    For Example:

    var ref = window.open(url, '_blank');
    ref.addEventListener('loadstart', function(event) {
             alert('start loading');
    });
    

    loadstop:The event fires when the InAppBrowser stops to load a URL.
    For Example:

    var ref = window.open(url, '_blank');
    ref.addEventListener('loadstop', function(event) {
             alert('stop loading');
    });
    

    loaderror:This event fires when the InAppBrowser encounters an error when loading a URL.

    var ref = window.open(url, '_blank');
     ref.addEventListener('loaderror', function(event) {
                 alert('URL loading Error:'+event.code);
     });
    

    exit: This event fires when the InAppBrowser window closed.

    var ref = window.open(url, '_blank');
     ref.addEventListener('exit', function(event) {
                 alert('exit');
     });
    

    Note: InAppBrowser is behave like a standard web browser so it cant access Cordova APIs.


    Hope this will help you.:)

 1 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: