Ola Karlsson
Ola Karlsson

Reputation: 9193

Domain wide localStorage fall-back for I6 & IE7?

In our current project, we're using HTML 5 localStorage with fall-back to global storage for Firefox and userdata behaviors for IE6/IE7. The fall-back is provided through a JS script called jStorage.

This worked ok, until we started testing in IE6/IE7, even though it "works", it turns out that there's a restriction in userdata behaviour which locks it down so storage can only be set and read on the same URL or as MSDN puts it "For security reasons, a UserData store is available only in the same directory and with the same protocol used to persist the store".

Hence if I set a value on one page and then navigate to another, although I'm on the same site, it won't work. Which for us pretty much renders it unusable as a fall-back for local storage, which is scoped per domain.

Has anyone come across this problem before and found a decent solution?
Any ideas or thoughts will be appreciated.

Upvotes: 6

Views: 921

Answers (3)

Erik
Erik

Reputation: 93

Remy Sharp's polyfill will do that.

https://gist.github.com/remy/350433

Upvotes: 1

Sergey Ilinsky
Sergey Ilinsky

Reputation: 31535

A theoretical solution would be:

  1. dynamically create a hidden "proxy" iframe accessing a static document retrieved from a location of your convenience, say http:/domain/proxy.html
  2. proxy access to the DOM element in the iframe to persist/fetch data

Upvotes: 0

Fabrizio Calderan
Fabrizio Calderan

Reputation: 123377

if the problem is to get data across two page in different paths, but in the same domain, you could try one of these (note: i didn't try: i'm just trying to be creative)

  1. Use url rewriting (with an .htaccess) so you can access /path1/page1 and /path2/page2 with a single path-rewritten/page1 and path-rewritten/page2

  2. if you are in /path2/page2 you could load an invisible iframe loading a page in /path1 in which you get the data stored in some data structure that you pass in the parent document.
    Since page1 and page2 are - per hypothesys - in the same domain you can make the page1 and iframe communicate each other via javascript.

btw good question.

Upvotes: 0

Related Questions