Activity indicator on links within a web view
By default, my web view shows an activity indicator when the window first loads, which is great.
I need to extend that so that once the first page in the web view loads, if I click a link inside the web view, the activity indicator shows while the next page loads.
I couldn't seem to find an example of that anywhere, but if there is example code, I'd love to see it.
Thanks in advance,
Peter
2 Answers
-
Accepted Answer
Hi Peter,
you can show an activity indicator when loading another page with:
webview.addEventListener("beforeload", function(e) { // code }
Then, when the page has finished loading you can hide the activity indicator with:
webview.addEventListener("load", function(e) { // code }
That should do the trick.
-
webview.addEventListener("beforeload", function(e)
{showActivity();
setTimeout(function() {
hideActivity();
}, 7000);
});