Ex DOM Storage ããªãªã¼ã¹ãã¾ãã
çµæ§åã«ä½ã£ã¦ãããã ãã©ãIE6, IE7 ã§ãåä½ãã DOM Storage ãä½ã£ãã®ã§ããã¡ãã¨åç¥ãã¾ãã
追è¨
- ã¡ãªã¿ã«ãµã¼ãã¼ã«ãã¡ã¤ã«ç½®ãã ãã§åãã¾ããã¦ã¼ã¶ã¼ã«ä½ãã¤ã³ã¹ãã¼ã«ãããå¿ è¦ã¯ããã¾ããã(2008-09-24T11:45:56+09:00)
- CodeReposにソースを移動ãã¾ããã(2008-09-24T12:37:24+09:00)
Ex DOM Storage
- dist
- http://svn.coderepos.org/share/lang/javascript/exdomstorage/tags/0.01/
- source
- http://svn.coderepos.org/share/lang/javascript/exdomstorage
- sample
- http://svn.coderepos.org/share/lang/javascript/exdomstorage/trunk/sample/index.html (Fx2, 3 ã§ãåãããã«ãã¾ãããã¾ã ã¡ãã£ã¨ãµã³ãã«ã«ãã°ããã£ã½ã)
ã½ã¼ã¹ã¯ããã CodeRepos ã«ç§»åãããããªã¨æãã¾ãã
DOM Storage ã£ã¦ãªãã ã
HTML5 ã§ä»æ§åããã¦ããã¯ã©ã¤ã¢ã³ããµã¤ãã¹ãã¬ã¼ã¸ã«é¢ããä»æ§ã DOM Storage ã§ãã
å ·ä½çã«ã¯ã
- localStorage
- sessionStorage
ã¨è¨ãäºã¤ã®ã¹ãã¬ã¼ã¸ãåå¨ãã¦ãå ±ã«ãã¡ã¤ã³åä½ã§ã¯ã©ã¤ã¢ã³ããµã¤ãã«ãã¼ã¿ãä¿ååºæ¥ã¾ããã
- localStorage
- æ°¸ç¶çã«ä¿å
- sessionStorage
- ãã©ã¦ã¶ãéããã¨æ¶ãã
ã¨è¨ãéããããã¾ãã
使ãæ¹ã¯ç°¡åã§ã
localStorage.foo = "zigorou";
ã®ããã«ä»£å ¥ãã¦ããã¨ããã®ãã¡ã¤ã³åä½ã§ foo ã«ä»£å ¥ãã "test" ã¨è¨ãå¤ã¯ä¿åããããã¡ã¤ã³åä½ã§å ±æããã以éã¯æ示çã«æ¶ããªãéãã¯ãlocalStorage.foo ã¨è¨ãåç §ã§ "test" ã¨è¨ãå¤ãåå¾ããäºãåºæ¥ã¾ãã
ç¾å¨ãããå®è£ ãã¦ãããã©ã¦ã¶ã¯ IE8 ã¨ãé¨åçã« Fx2, Fx3 *1 ã¨ãªã£ã¦ãã¾ãã
ãã㨠Safari ã® trunk ã§ã使ããããã§ãã(id:amachang è«)
使ãæ¹
サンプル ãè¦ã¦é ãã®ãä¸çªæ©ãã®ã§ããã詳ãã解説ãã¦ããã¾ãã
Content-Type ãè¨å®ãã
Ex DOM Storage ã§ã¯ IE ç¬èªæ©è½ã§ãã DHTML Behavior ã使ã£ã¦ãã¾ããããã«ã¤ãã¦ã¯å¥ã®ã¨ã³ããªã§è§£èª¬ãããã¨æãã¾ãããé å¸ãã¡ã¤ã«ã«ãã exdomstorage.htc ã«æ£ãã Content-Type ãè¨å®ããå¿ è¦ãããã®ã§ãä¾ãã° Apache ã§ããã°ãhttpd.conf ãªã©ã§ã
AddType text/x-component .htc
ã¨è¨å®ãã¦ç½®ãå¿ è¦ã(ãããã)ããã¾ãã
ãã¡ã¤ã«ãç½®ã
ã¨ããäºã¤ã®ãã¡ã¤ã«ãå¿ ãåããã£ã¬ã¯ããªã«é ç½®ãã¦ä¸ããã
Ex DOM Storage ãèªã¿è¾¼ã
IE6, 7 ã ãã«èªã¾ãããã®ã§ã条件付きコメント ãç¨ãã¦ãã¼ããã¾ãã
<!--[if lt IE 8]> <script type="text/javascript" src="/path/to/exdomstorage.js"></script> <![endif]-->
ããã§ä½¿ããããã«ãªãã¯ãã§ãã
ç¹å¾´ã¨å¶ç´ã«é¢ãã¦
onstorage ã¤ãã³ã
document ãªãã¸ã§ã¯ãã«å¯¾ã㦠fire ããã¾ããã¤ã¾ãã
localStorage.setItem("name", "ZIGOROu");
ãªã©ãããéã«ã
document.attachEvent("onstorage", function(evt) { alert(evt.key + " was changed to " + evt.newValue + " from " + evt.oldValue); });
ã¨ãã¦ããäºã§ãonstorage ã¤ãã³ããææããäºãåºæ¥ã¾ãã
ä½ããããã¯å¶ç´ã§ããæ¬æ¥ã® DOM Storage ã¯åä¸ãã¡ã¤ã³ã®ãã¼ã¸ãéãã¦ã¤ã³ãã¦ãè¤æ°åå¨ãã¦ããå ´åããã®ãã¡ã®ä¸ã¤ã§ onstorage ã¤ãã³ãã fire ãããã¨ä»ã®ã¦ã¤ã³ãã¦ã® document ãªãã¸ã§ã¯ãã«å¯¾ãã¦ã onstorage ã¤ãã³ãã fire ããã¾ãããEx DOM Storage ã§ã¯ããã¾ããã*2
remainingSpace ããããã£
Storage - Web APIs | MDN ã«ããã¾ãããIE8 ã«ã¯ Storage ãªãã¸ã§ã¯ãã«å¯¾ã㦠remainingSpace ããããã£ãåå¨ãã¾ãã
ããã¯å¾ã©ãããã Storage ã«ä¿ååºæ¥ããã¨è¨ãç®å®(byteåä½)ã«ãªãã®ã§ãããEx DOM Storage ã§ãä¸å¿å®è£ ãã¦ã¾ãã
Ex DOM Storage ã®ããã¯ã¨ã³ã㯠userData behavior ãªã®ã§ããããã 64Kbyte ä¿ååºæ¥ãã®ã«å¯¾ãã¦ãIE8 ã§ã® native 㪠DOM Storage 㯠5,000,000 byte (ç´5MB) ä¿ååºæ¥ã¾ãã
å®ã¯ userData behavior ãã¼ã¹ã§ããã£ã¨å®¹éãå¢ãããäºã¯åãã£ã¦ãããã§ãããé度éè¦ã«ããã®ã§ç¾å¨ã®å¶ç´ã®ã¾ã¾ã«ãã¦ãã¾ãã
swf ãã¼ã¹ã®ã¯ã©ã¤ã¢ã³ããµã¤ãã¹ãã¬ã¼ã¸ã¨ã®éã
ãã㯠id:amachang ã«æãã¦è²°ã£ããã ãã©ãonload ã¤ãã³ãå¾ãããªã㨠swf ã«ã¢ã¯ã»ã¹åºæ¥ãªãã®ã«å¯¾ãã¦ãEx DOM Storage ã¯ãã®ã©ã¤ãã©ãªãèªã¿è¾¼ãã ç´å¾ãã使ããããã«ãªãã¾ãã
ä½è¨ãªè¦ç´ ãå¢ãã¾ãï¼ï¼ (追è¨:2008-09-24T11:45:56+09:00)
å®ã¯ Storage ãªãã¸ã§ã¯ãã®å®æ 㯠script è¦ç´ ã«ãªã£ã¦ãã®ã§ãheadè¦ç´ å ã«äºã¤ä½è¨ãª script è¦ç´ ãå¢ãã¦ãã¾ãã¾ãã
ã¨è¨ã訳ã§
æ軽ã«ä½¿ããããã«ãªã£ã¦ããã§ãæ¯éã試ãä¸ãããã¾ããã°å ±åçãããã¾ãããããè¿ãã® id:ZIGOROu ã¾ã§ã声æãä¸ããã
SEE ALSO
*1:http://developer.mozilla.org/Ja/DOM/Storage ãåç §ã®äºãç°¡åã«è¨ãã°å¤ãä»æ§ã«åã£ã¦ãã¦ãlocalStorage ãå®è£ ããã¦ãªã代ããã« globalStorage ãå®è£ ããã¦ãããglobalStorage 㧠localStorage ã¯ä»£æ¿å¯è½
*2:ã¨è¨ãã HTC 㨠JS ã ãããä¸å¯è½