Show loader on InAppBrowser while loading

For InAppBrowser You've to install the plugin 'cordova-plugin-inappbrowser' :

cordova plugin add cordova-plugin-inappbrowser

For Dialogs You've to install the plugin 'cordova-plugin-dialogs' :

cordova plugin add cordova-plugin-dialogs
Then write this code for open inappbrowser :


var ref = window.open(encodeURI('http://www.google.com', '_blank', 'location=yes');

ref.addEventListener('loadstart', inAppBrowserbLoadStart);
ref.addEventListener('loadstop', inAppBrowserbLoadStop);
ref.addEventListener('loaderror', inAppBrowserbLoadError);
ref.addEventListener('exit', inAppBrowserbClose);


function inAppBrowserbLoadStart(event) {
   navigator.notification.activityStart("Please Wait", "It'll only take a moment...");
}

function inAppBrowserbLoadStop(event) {
   navigator.notification.activityStop();
}

function inAppBrowserbLoadError(event) {
   navigator.notification.activityStop();
}

function inAppBrowserbClose(event) {
   navigator.notification.activityStop();
   ref.removeEventListener('loadstart', inAppBrowserbLoadStart);
   ref.removeEventListener('loadstop', inAppBrowserbLoadStop);
   ref.removeEventListener('loaderror', inAppBrowserbLoadError);
   ref.removeEventListener('exit', inAppBrowserbClose);
}