html5 - html 5 web app cache download complete javascript alert? -
i'm creating basic offline web app using cache.manifest
but have under 5mb of cache downloading do. , wondering if there way of having popup alert runs once when cache download complete?
thanks
i found debugger helps me debug wether have missed on manifest, don't know whether can in anyway?
<script> var cachestatusvalues = []; cachestatusvalues[0] = 'uncached'; cachestatusvalues[1] = 'idle'; cachestatusvalues[2] = 'checking'; cachestatusvalues[3] = 'downloading'; cachestatusvalues[4] = 'updateready'; cachestatusvalues[5] = 'obsolete'; var cache = window.applicationcache; cache.addeventlistener('cached', logevent, false); cache.addeventlistener('checking', logevent, false); cache.addeventlistener('downloading', logevent, false); cache.addeventlistener('error', logevent, false); cache.addeventlistener('noupdate', logevent, false); cache.addeventlistener('obsolete', logevent, false); cache.addeventlistener('progress', logevent, false); cache.addeventlistener('updateready', logevent, false); function logevent(e) { var online, status, type, message; online = (navigator.online) ? 'yes' : 'no'; status = cachestatusvalues[cache.status]; type = e.type; message = 'online: ' + online; message+= ', event: ' + type; message+= ', status: ' + status; if (type == 'error' && navigator.online) { message+= ' (prolly syntax error in manifest)'; } console.log(message); } window.applicationcache.addeventlistener( 'updateready', function(){ window.applicationcache.swapcache(); console.log('swap cache has been called'); }, false ); setinterval(function(){cache.update()}, 10000); </script>
in order check when cache download complete, looking cached event. can checked similar 1 have above.
window.applicationcache.addeventlistener('cached', function() { // need success alert('i'm done!'); }, false );
Comments
Post a Comment