![](/img/trans.png)
[英]Is it possible to use any HTML5 fanciness to export local storage to Excel?
[英]Is it possible to use HTML5 local storage to share data between pages from different sites?
我想在用戶端創建數據,讓其他URL的javascript也可以訪問它。 我知道相同的原始政策,但我想知道是否有可能創建一些例外。 或者,我可以使用任何技巧/功能嗎?
我知道的最好的技巧是使用iframe和postMessage
API從外部域訪問localStorage。
這種技術很簡單:
您的數據域需要偵聽message
事件:
document.addEventListener(“message”,handler,useCapture);
handler將負責訪問localStorage
並將其內容發布到源域
postMessage
API調用數據域上的handler
函數https://developer.mozilla.org/en-US/docs/DOM/window.postMessage 為了保護您的數據,您可以使用HTTP標頭X-Frame-Options ALLOW-FROM uri https://developer.mozilla.org/en-US/docs/HTTP/X-Frame-Options?redirectlocale=en-US&redirectslug=The_X -frame-OPTIONS_response_header
希望它會有所幫助。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.