Quantcast
Channel: Appcelerator Developer Center Q&A Unanswered Questions 20
Viewing all articles
Browse latest Browse all 8068

Webview 'beforeload' and 'load' events fire several times

$
0
0

I am using the 'beforeload' and 'load' events for my webview to update the page title bar with 'Loading...' ad then when the 'load' event fires it changes to show the page title and URL (similar to Facebook):

Facebook example

Problem is, both events can be fired several times during the load and sometimes it will get stuck on 'Loading...' and not show the page title - the 'beforeload' event is fired more than once, but the 'load' event isn't fired the same amount of times.

I.E 'beforeload' 'load' 'beforeload'

and then it stops and doesn't do a final 'load' event.

 

Is there any way to fix this?

Here's my code:

externalWebViewCont.children[0].addEventListener('beforeload', function(e) {
    externalWebViewTitlebarTitle.text = 'Loading...';
    externalWebViewTitlebarURL.text = '';
});
 
externalWebViewCont.children[0].addEventListener('load', function(e) {
    externalWebViewTitlebarTitle.text = externalWebViewCont.children[0].evalJS("document.title");
    externalWebViewTitlebarURL.text = externalWebViewCont.children[0].url;
});

Viewing all articles
Browse latest Browse all 8068

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>