Reputation: 9193
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
Reputation: 93
Remy Sharp's polyfill will do that.
https://gist.github.com/remy/350433
Upvotes: 1
Reputation: 31535
A theoretical solution would be:
Upvotes: 0
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)
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
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