Experimental Lex

Playing with words.

HTML5 Storage in EPUB

I’ve been working on some personal ebook projects recently and wanted to find out if I could use HTML5 storage in an iBooks EPUB.  The answer is not quite.  If you have information to the contrary, please let me know.

Here’s a code sample I used to increment the score for a user as they completed different activities.

function addScore() { 
var db = window["localStorage"]; 
var counter = document.getElementById("flipcount"); 
if (db["score"] != undefined) 
{ var c = parseInt(db["score"]); 
db.setItem("score", c+1); 
counter.innerText = db["score"]; 
} else { 
db.setItem("score", 1); 
counter.innerText = 1; 
}
}

It seems the iBooks does not recognize “localStorage”, though it does recognize “globalStorage”. Unfortunately, it doesn’t save the information after you leave a page.  Ideally, it would maintain it in a session that is accessible across all of the pages in a single ebook.  I hope this is fixed in an upcoming iBooks update.

Advertisements

Comments are closed.

%d bloggers like this: