www.webdeveloper.com
Results 1 to 5 of 5

Thread: DOM Storage ?

  1. #1
    Join Date
    Apr 2006
    Location
    Houston
    Posts
    1,374

    DOM Storage ?

    I must have been living under a rock for the last few months. Just found out that IE8 and Firefox support DOM Storage.

    http://msdn.microsoft.com/en-us/libr...8VS.85%29.aspx
    https://developer.mozilla.org/en/DOM/Storage

    Anyone using it yet? Any cross browser problems I need to look out for ?

  2. #2
    Join Date
    Dec 2008
    Posts
    488
    This is cool! Too bad we won't be able to make it work for every user for another 4 years (when everyone finally upgrades to at least IE8). I think FF and Safari have had it for a while (FF2 and Safari 4). I wonder if this might provide a fix for AJAX caching issues?

  3. #3
    Join Date
    Apr 2006
    Location
    Houston
    Posts
    1,374
    I think that with Windows 7 popularity that we will see IE8 gain market share mare quickly that most people think

  4. #4
    Join Date
    Dec 2008
    Posts
    488
    You still have a lot of software that must connect through IE, and a lot of them will only work in IE6. So, people think that's the only browser they're allowed to use on their computer, not realizing they can also have a new version of chrome or firefox. I'm talking about a smaller market of course, mostly tech support people (ironically).

  5. #5
    Join Date
    Jul 2008
    Location
    urbana, il
    Posts
    2,787

    why wait?

    Quote Originally Posted by jamesbcox1980 View Post
    This is cool! Too bad we won't be able to make it work for every user for another 4 years (when everyone finally upgrades to at least IE8). I think FF and Safari have had it for a while (FF2 and Safari 4). I wonder if this might provide a fix for AJAX caching issues?
    here's an all in one i packed up last summer:

    Code:
    (function _buildStorageDevice(){var appName=location.href.split(/\//g)[3];var D=document;var d1=new Date;var expry=(new Date(d1.getFullYear()+10,1,1)).toGMTString();function setCookie(nm,valu){D.cookie=nm+"="+escape(valu)+"; expires="+expry;}
    function getCookie(k){var d=D.cookie||"";var pairs=d.split(k+"=");if(pairs&&pairs[1]){return unescape(pairs[pairs.length-1].split(";")[0]);}}
    if(window.localStorage&&!window.globalStorage){window.globalStorage={};window.globalStorage[document.domain]=localStorage;}if(window.globalStorage){function store(key,val){if(val){globalStorage[document.domain][appName+key]=val;}else{try{var tm=globalStorage[document.domain][appName+key]||"";if(tm){tm=tm.toString();}}catch(rr){return"";}return tm||"";}return;}}else{function store(key,val){if(val){setCookie(appName+key,val);}else{return getCookie(appName+key);}}}
    function iestorer(){var D=document;if(!D.createStyleSheet){return;}var tCSS=D.createStyleSheet();tCSS.addRule(".userData","behavior:url(#default#userdata)",0);var Static=D.createElement("input");var Q=function(z,x){Static.setAttribute(z,x);};Q("type","hidden");Q("id","dandavisStatic");Q("className","userData");D.getElementsByTagName("head")[0].appendChild(Static);var s=Static;function ies(k,v){if(!v){s.load("oXMLStore");var t=s.getAttribute(appName+k);return unescape(t)||"";}else{s.setAttribute(appName+k,escape(String(v)));s.save("oXMLStore");}}
    window.store=window.Store=ies;}
    iestorer();window.Store=window.store=store;}());
    
    
    //example usage:
    
    Store("myname", "dan")//store a value (dan) under the key "myname"
    
    alert(Store("myname"))  //read value of store's "myname" key (dan)
    should work in IE5+,IE8,FF3,C3,S3, and O10.
    anything less falls back to cookies, so use it without fear.

    note that in ie5+6, you only get 64kb (still about 16 cookies worth), 100-500kb in IE7.
    IE8 and others give you the full 5MB.

    enjoy!
    Last edited by rnd me; 12-04-2009 at 08:03 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles