LocalStorage object available in iBooks?

Does anyone know if the local storage object is available in html widgets? Can we store and retrieve data in html widgets inside iBooks?

Posted on Jan 26, 2012 6:38 AM

Reply
26 replies

Feb 16, 2012 1:35 PM in response to multimedial

What about the database object?
According to Apple's documentation, it seems as if the Web Database object should also be available - anyone got news on this?


Here is my source

https://developer.apple.com/library/safari/#documentation/iPhone/Conceptual/Safa riJSDatabaseGuide/Introduction/Introduction.html


It looks more and more as if the rendering engine of iBooks is nothing more than a (webkit-based) Safari browser, right?

Feb 17, 2012 6:15 AM in response to multimedial

@multimedial


On the surface, I would agree, functionality and capabilities seems to operate just like webkit, with one very big difference. It appears as if each time you enter a widget, the system instantiates a new safari instance in memory. Once you have moved a few pages away from the widget, it wipes that safari instance. In this way, any variables, cookies, even session identifiers disappear. At least, that has been my experience thus far. I would love yo hear of anyones success in this arena.

Feb 17, 2012 7:36 AM in response to Jared_Booth

Here is some sample code that stores and gets some text from localStorage:


<textarea id="sometext" rows="15" cols="100"></textarea>

</br>

<input type="submit" value="Save to localStorage" onclick="save_localstorage()" />


<script type="text/javascript">

var sometext = localStorage.sometext;

if (sometext) {

document.getElementById("sometext").value = sometext;

}

function save_localstorage() {

localStorage.sometext = document.getElementById("sometext").value;

}

</script>


I've also placed it in an example widget for you to download at:


http://www.classwidgets.com/static/LocalStorageTest.wdgt.zip

Apr 15, 2012 9:12 AM in response to Rhys_Jones

Rhys_Jones wrote:


Here is some sample code that stores and gets some text from localStorage:


<textarea id="sometext" rows="15" cols="100"></textarea>

</br>

<input type="submit" value="Save to localStorage" onclick="save_localstorage()" />


<script type="text/javascript">

var sometext = localStorage.sometext;

if (sometext) {

document.getElementById("sometext").value = sometext;

}

function save_localstorage() {

localStorage.sometext = document.getElementById("sometext").value;

}

</script>


I've also placed it in an example widget for you to download at:


http://www.classwidgets.com/static/LocalStorageTest.wdgt.zip


@Rhys: Can you confirm if this still works? I'm also having trouble with localStorage - I inserted the widget you supplied and it fails to work. If I close the widget and reopen it, the storage is wiped. I'm using iBooks Author 1.1 (190) and iBooks 2.1 (876) on an iPad 2.


Thanks.

Nov 13, 2012 3:50 PM in response to multimedial

multimedial wrote:


What about the database object?
According to Apple's documentation, it seems as if the Web Database object should also be available - anyone got news on this?


Well, I don't know if it qualifies as "news" given the age of this thread, but yes, I've tried and the JavaScript database seems to work. This opens up the possbility for storing some rather rich data with complex relationships. Cool.


🙂


-Steve

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

LocalStorage object available in iBooks?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.