Wednesday, September 24th, 2008
Ex DOM Storage gives us hope for IE 6+
Toru Yamaguchi has built a very cool shim, ExDOMStorage, which implements the HTML 5 DOM Storage API for IE 6 and 7.
It does so by strapping in the functionality via an HTC behaviour:
-
-
(function() {
-
if (window["localStorage"] && window["sessionStorage"])
-
return;
-
-
with({ nodeSet: document.getElementsByTagName("script"), storages: ["localStorage", "sessionStorage"] }) {
-
var loader = nodeSet.item(nodeSet.length - 1);
-
var src = loader.getAttribute("src");
-
var behavior_uri = src.replace(/\/\w+\.js$/, '/exdomstorage.htc');
-
-
for (var i in storages) with ({ storage: document.createElement('script'), name: storages[i] }) {
-
window[name] = storage;
-
loader.parentNode.appendChild(storage);
-
storage.addBehavior(behavior_uri + "#" + name);
-
}
-
}
-
})();
-












U could also store data using window.name… session wise.. IE6 (sp3+) handles it fine…
but that looks hot to :P
Just a side note (not a competitive one); MooTools has something similar that it calls “Element.Storage”. Just FYI.
This is something I was planning to build when I had the time so thank you Toru Yamaguchi. Much better solution than what I had in mind (Flash ShareObjects.
Buddy - Graphic Designer from Katy, TX