Wednesday, September 24th, 2008

Ex DOM Storage gives us hope for IE 6+

Category: Browsers, IE

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:

javascript

  1. (function() {
  2.    if (window["localStorage"] && window["sessionStorage"])
  3.      return;
  4.  
  5.    with({ nodeSet: document.getElementsByTagName("script"), storages: ["localStorage", "sessionStorage"] }) {
  6.      var loader = nodeSet.item(nodeSet.length - 1);
  7.      var src = loader.getAttribute("src");
  8.      var behavior_uri = src.replace(/\/\w+\.js$/, '/exdomstorage.htc');
  9.  
  10.      for (var i in storages) with ({ storage: document.createElement('script'), name: storages[i] }) {
  11.        window[name] = storage;
  12.        loader.parentNode.appendChild(storage);
  13.        storage.addBehavior(behavior_uri + "#" + name);
  14.      }
  15.    }
  16. })();

Posted by Dion Almaer at 7:38 am
2 Comments

+++--
3.2 rating from 31 votes

2 Comments »

Comments feed TrackBack URI

U could also store data using window.name… session wise.. IE6 (sp3+) handles it fine…

but that looks hot to :P

Comment by V1 — September 24, 2008

Just a side note (not a competitive one); MooTools has something similar that it calls “Element.Storage”. Just FYI.

Comment by anewton — September 24, 2008

Leave a comment

You must be logged in to post a comment.