Applicationcache keeps raising "error" event
I have a web page that is referencing a manifest file. The javascript on the page handles the "error" event on the applicationCache. Every time I navigate to the page the "error" event fires.
When this has happened in the past it has always been because one of the files listed in the manifest would not load. I've checked each one individually and they all load.
I am writing this to run on iOS so I'm only concerned with whether it works in Safari. I've tried it using Safari 5.0.2 on Windows and iPod 4.2.1 and got the same results.
Main page (default.aspx)
<!DOCTYPE HTML>
<html manifest="manifest.aspx">
<head>
...
manifest.aspx
CACHE MANIFEST
# Cache manifest version 99
default.aspx
default.css
scripts/jquery-json.js
script开发者_Go百科s/jquery-min.js
scripts/app.js
images/button.png
images/error.png
app/assessment.aspx
app/discharge.aspx
app/episode.aspx
app/guide.aspx
app/notes.aspx
app/note check.aspx
app/supplement.aspx
app/warning.aspx
app.js
...
window.applicationCache.addEventListener("progress", progressCache, false);
window.applicationCache.addEventListener("cached", doneCache, false);
window.applicationCache.addEventListener("noupdate", noupdateCache, false);
window.applicationCache.addEventListener("updateready", updateCache, false);
window.applicationCache.addEventListener("error", errorCache, false);
window.applicationCache.addEventListener("obsolete", obsoleteCache, false);
function errorCache() {
if (!navigator.onLine) {
console.log("You're not online");
} else {
console.log("An error has occurred");
}
}
...
I tried adding a parameter to the errorCache function, but it doesn't seem to provide any more information.
function errorCache(e) {
It turns out that Safari doesn't like file names in the manifest that contain spaces.
Once I renamed
app/note check.aspx
to
app/notecheck.aspx
it started working.
精彩评论