Access root domain's localStorage from subdomain

不想你离开。 提交于 2019-11-28 23:46:38

...Why not use GM_setValue and GM_getValue?

EDIT: I did a little digging. Look what I found!

http://www.opera.com/docs/userjs/specs/#scriptstorage

It claims to work the same as localStorage, but it's scoped per-script, rather than per-website. Should work perfect for your use case.

You can not.

For security reasons the browser only grants access to data stored with localStorage within the same domain. This is due to the fact, that on some systems different subdomains belong to different people / websites.

See for example: http://msdn.microsoft.com/en-us/library/cc197062(VS.85).aspx

Each domain and subdomain has its own separate local storage area. Domains can access the storage areas of subdomains, and subdomains can access the storage areas of parent domains. For example, localStorage['example.com'] is accessible to example.com and any of its subdomains. The subdomain localStorage['www.example.com'] is accessible to example.com, but not to other subdomains, such as mail.example.com.

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