Can I use the same HTML5 browser storage, across different domains?

有些话、适合烂在心里 提交于 2019-12-24 04:15:08

问题


There are a couple of different approaches for choosing an HTML5 browser storage (IndexedDB, Web Storage), but from what I read in the spec, the "same origin policy applies".

Is there a way to keep data inside the browser and have it available from both www.domain1.com/myapp1 and www.domain2.com/myapp2?


回答1:


Cross-Document Messaging

You can use a technique called cross-document messaging to accomplish this. There is an article here that outlines how to implement it, but it's basically where two domains talk to each other and pass information instead of directly accessing their data store, which the HTML 5 spec prohibits.




回答2:


That seems fraught with peril, I'm going to say that there's something in the spec to prevent that. Otherwise you could inject bad data into someone elses app.



来源:https://stackoverflow.com/questions/5651068/can-i-use-the-same-html5-browser-storage-across-different-domains

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