如何从根域访问子域的html5 localStorage? [英] how to access a subdomain's html5 localStorage from the root domain?

查看:87
本文介绍了如何从根域访问子域的html5 localStorage?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我拥有www.mydomain.com和mydomain.com时,他们每个人都会获得一个单独的localStorage.

When I have www.mydomain.com and mydomain.com, each of them gets a separate localStorage.

我在这里已阅读 http://msdn .microsoft.com/en-us/library/cc197062(VS.85).aspx ,我可以从mydomain.com根域访问www.mydomain.com的localStorage.但是我该怎么做呢?我已经尝试过localstorage ['www.mydomain.com'].getItem ...,但这似乎不起作用.

I've read here http://msdn.microsoft.com/en-us/library/cc197062(VS.85).aspx that I can access www.mydomain.com's localStorage from mydomain.com root domain. But how do I do that? I've tried localstorage['www.mydomain.com'].getItem... but that doesn't seem to work.

那是IE特定的吗?我在Safari 5中尝试过.

Is that IE specific? I tried in Safari 5.

谢谢.

推荐答案

我写了一个很酷的库,它使用共享的iframe和发布消息解决了跨域本地存储问题.它附带了angularjs支持.在 github

I've wrote a cool library that solves the cross domain local storage problem using shared iframe and post messages. It event comes with angularjs support. Check it out on github

这篇关于如何从根域访问子域的html5 localStorage?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆