HTML and CSS Reference
In-Depth Information
opeRa'S DRagonFly
DragonFly comes shipped with Opera, and from the Storage tab
you can access all the data stored in association with the cur-
rent page. In particular, there are separate tabs for Local Storage
and Session Storage to inspect all the data linked with those
data stores ( figure 6.3 ).
fIgure 6.3 Opera's DragonFly
debugger to inspect storage.
Fallback options
As the storage API is relatively simple, it's possible to replicate
its functionality using JavaScript, which could be useful if the
storage API isn't available.
For localStorage , you could use cookies. For sessionStorage ,
you can use a hack that makes use of the name property on the
window object. The following listing shows how you could repli-
cate sessionStorage functionality (and ensure the data remains
locked to the current window, rather than leaking as cookies
would) by manually implementing each of the Storage API meth-
ods. Note that the following code expects that you have JSON
support in the browser, either natively or by loading Douglas
Crockford's library.
if (typeof sessionStorage === 'undefined') {
sessionStorage = (function () {
var data = ? JSON.parse(
¬ name) : {};
return {
clear: function () {
Search WWH ::

Custom Search