Javascript:在标签之间共享数据 [英] Javascript: sharing data between tabs
问题描述
在浏览器中打开标签页之间共享数据的最佳方法是什么?
What is the best way to share data between open tabs in a browser?
推荐答案
要获得更现代化的解决方案,请查看 https://stackoverflow.com/a/12514384/270274
For a more modern solution check out https://stackoverflow.com/a/12514384/270274
引用:
我坚持使用
localStorage localStorage中提到的共享本地数据解决方案
。它似乎是可靠性,效率和浏览器兼容性方面的最佳解决方案。
I'm sticking to the shared local data solution mentioned in the question using
localStorage
. It seems to be the best solution in terms of reliability, efficiency, and browser compatibility.
localStorage
在所有现代浏览器。
当其他标签对<更改<其他标签时,会触发存储
事件code> localStorage的。这对于沟通来说非常方便。
The storage
event fires when other tabs makes changes to localStorage
. This is quite handy for communication purposes.
参考:
http://dev.w3.org/html5/webstorage/
http://dev.w3.org/html5/webstorage/#the-storage-event
这篇关于Javascript:在标签之间共享数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!