Javascript/HTML Storage Options Under File Protocol (file://)

后端 未结 2 423
终归单人心
终归单人心 2020-12-03 07:06

I am developing an html application that is essentially a series of pages like a book. Within this application, I would like to store several JavaScript variables across pag

相关标签:
2条回答
  • 2020-12-03 07:38

    A buddy of mine at work helped me out with this problem by sharing his implementation of using window.name to store data across pages of a single window/session.

    A similar implementation (and discussion around the method) can be found here: http://ajaxian.com/archives/whats-in-a-windowname

    Preliminary tests I've been doing on this method look very promising. I tested this, under the file protocol (loading page from desktop, a.k.a. - "file:\") on the following browsers. It worked on all of them!!

    • IE 6
    • IE 7
    • IE 8
    • IE 9
    • FF 3.6
    • FF 4
    • Chrome 11
    • Opera 10
    • Safari 4

    I have not yet done any testing as to how much data you can store here, but the internets seem to agree on a value of 2 MB.

    Sources, links, more information

    • JavaScript Programmer's Reference (Google Books)
    • Cookie-less Session Variables in JavaScript - Sitepoint Article
    0 讨论(0)
  • 2020-12-03 07:53

    On Webkit (Chromium 12.0.742.21 dev-m) localStorage over file protocol worked fine to me.

    On Gecko it's reported and should be improved soon.

    You can even find a workaround, but I recommend that you develop using Chrome nightly build. So you'll not lose time moving it back to localStorage in future.

    0 讨论(0)
提交回复
热议问题