I am trying to display a loading indicator in Phonegap InAppBrowser when a page is loading using the following code:
var ref;
ref = window.open('http://www.google.com', '_top', 'location=no');
ref.addEventListener('loadstart', function(event) {
//navigator.splashscreen.show();
navigator.notification.activityStart("", "loading");
});
ref.addEventListener('loadstop', function(event) {
//navigator.splashscreen.hide();
navigator.notification.activityStop();
});
It doesn't display the indicator. I think that the z-index is lower then z-index of InAppBrowser.
If I use a splash screen instead of loading indicator it works.
have a look in the link it explain its in detail. This loading screen do not work with ios but its working absolutely fine on android http://javacourseblog.blogspot.in/2014/02/show-loading-screen-in-phonegap-app.html
You can open
InAppBrowser
inhidden
mode, meanwhile display a spinner, and when it finishes loading hide the spinner and show theInAppBrowser
:For me, hiding inappbrowser was giving some uncaught error if the page being loaded redirects to another! I had to keep the inappbrowser visible. I was able to inject a spinner to the inappbrowser for improving the user experience by avoiding the awkward white screen.
Custom Spinner
following solution has many alternatives, one can use an html file 'spinner.html' instead of hard-coding the code, but this specific approach is working across platform (nexus 5, pixel 1/2, iphone 6,7)
spinner will be overwritten by the actual page once it starts loading.