WHATWG だかの仕様でローカルに恒久保存領域があるらしいんだけど、
ローカルホストの時にバグがあるっぽい。
具体的には URI が "file:///X:/hoge.html" みたいな場合は
localhost 扱いにならない模様。
そこで、そんな時は無理やり URI を書き換えてしまうのはどうだろう?
<html> <head> <script type="text/javascript"> function OnLoad() { if (window.location.protocol == "file:") { if (window.location.host != "localhost") { var frontOfPathName = window.location.pathname.substring(0, 3); if (frontOfPathName != "///") { window.location = "file://localhost" + window.location.pathname; } else { // This document exists on a network-drive. // There is no way to resolve it to localhost smartly. alert("This document exists on a network-drive.\nThere is no way to resolve it to localhost smartly.\n"); } } } var storage = null; var exception = null; try { storage = window.globalStorage.namedItem("localhost.localdomain"); } catch (exception) { alert("" + exception); } if (storage != null) { storage.setItem("aiueo", 10); alert("" + storage.getItem("aiueo")); } } </script> </head> <body onload="OnLoad();"> </body> </html>
でも、ファイルがネットワークドライブにある場合の対処方法が思い浮かばない。