how to access a subdomain's html5 localStorage from the root domain?

南楼画角 提交于 2019-12-04 05:35:44

问题


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

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.

Is that IE specific? I tried in Safari 5.

Thank you.


回答1:


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



来源:https://stackoverflow.com/questions/3343645/how-to-access-a-subdomains-html5-localstorage-from-the-root-domain

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!