2012-11-20 11 views
6

Durante la memorizzazione nella cache del mio offline webapp ricevo un errore del tutto valida che viene visualizzato nella console del browser in questo modo:Come ottenere un messaggio di errore su un evento Errore cache Cache HTML5?

Application Cache Error event: Manifest changed during update, scheduling retry 

posso aggiungere un ascoltatore di essere informato che è avvenuto un errore.

window.applicationCache.addEventListener('error', function(e){ 
    //handle error here 
}, false); 

Come posso ottenere dettaglio errore, in questo caso "manifesto cambiato durante l'aggiornamento, la programmazione riprovare"?

risposta

1

ancora una questione valida oggi. Nel mio esempio, il mio log degli errori non restituisce nulla. Sto usando IE11.

<html xmlns="http://www.w3.org/1999/xhtml" manifest="icozum.appcache"> 

onChecking eventi incendi ma poi onError con lo stato di cache = 0 che è nocached.

window.applicationCache.onchecking = function (e) { 
     var doc = document.getElementById("cachestatus"); 
     if (doc != null) { 
      doc.innerHTML += "Checking the cache.\n"; 
     } 
} 

Poi onError

window.applicationCache.onerror = function (e) { 
    var doc = document.getElementById("cachestatus"); 
    if (doc != null) { 
     doc.innerHTML += "Cache error occurred." + applicationCache.status.toString() + "\n"; 
     console.log(e); 
     console.log("test"); 
    } 
} 

I dati visualizzati sullo schermo è

Controllo della cache. errore Cache occurred.0

Non c'è nessun dettaglio informazioni sull'errore nel gestore di eventi onError. Ho ottenuto il vero errore premendo F12. Ecco la schermata. C'è un modo per catturare questi dettagli nel gestore di eventi onError.

enter image description here

E finalmente ho capito il problema. L'errore non è dovuto alla mancanza del file. Il file di cache dell'app esiste, tuttavia in Windows, Visual Studio (2013)/IIS non riconosce l'estensione .appcache. La seguente sezione deve essere aggiunta al file web.config.

<system.webServer> 
    <staticContent> 
    <mimeMap fileExtension=".appcache" mimeType="text/cache-manifest"/> 
    </staticContent> 
</system.webServer> 
Problemi correlati