参考方案来自
https://connect.microsoft.com/IE/feedback/details/812563/ie-11-local-storage-synchronization-issues
原文如下:
IE 11 - Local Storage - Synchronization issues- by WalkMe
状态 :
|
描述
While working with two IE 11 windows,in each an iframe of the same domain,values stored in one iframe (using local storage) are not synchronized to the other iframe. This in contradiction to the specification (other browser act correctly).
由
AlexandreJobin在 2016/2/16 7:48 发送
I confirm that the @Vageesh Dwivedi solution works for me. Each time i have to write new data to the localStorage,i also create a dummy item and remove it right away and my tabs are now synced.
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Kiyokura在 2015/4/27 17:29 发送
I found a workaround (IE11 on Win8.1).
Add the following code,update of other tabs is synchronized well:
----
window.addEventListener("storage",function (e) {
// Dummy
},false);
Add the following code,update of other tabs is synchronized well:
----
window.addEventListener("storage",function (e) {
// Dummy
},false);
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
由 Vageesh Dwivedi 在 2015/3/4 6:14 发送
由 Vageesh Dwivedi 在 2015/3/4 6:14 发送
I also faced a similar issue.
Scenario : window 1 is domain.com and has an iframe of domainx.com,window 2 is domainx.com. I wanted localstorage based communication between window 1's iframe and window 2.
The listener and polling technique didn't work and indexedDB workaround was too big for this small problem. After a few hacks,the localStorage keys were synced when i did -
localStorage.setItem('dummy','dummyvalue');
localStorage.removeItem('dummy');
in iframe on window 1.
Scenario : window 1 is domain.com and has an iframe of domainx.com,window 2 is domainx.com. I wanted localstorage based communication between window 1's iframe and window 2.
The listener and polling technique didn't work and indexedDB workaround was too big for this small problem. After a few hacks,the localStorage keys were synced when i did -
localStorage.setItem('dummy','dummyvalue');
localStorage.removeItem('dummy');
in iframe on window 1.
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
由
WalkMe
在 2014/2/5 4:03 发送
As a workaround we used indexed DB instead of local storage.
The indexed DB synchronizes well,but it is async compared to the local storage which is sync.
To overcome this difference we used web workers and gave them the job of writing the data,so it was done almost in parallel.
Still prefer an official solution :)
The indexed DB synchronizes well,but it is async compared to the local storage which is sync.
To overcome this difference we used web workers and gave them the job of writing the data,so it was done almost in parallel.
Still prefer an official solution :)
我的方法:
我的解决方案取自上文的前两种方法,即使用增加和移除虚假的item更新localStorage,同时定义使用window.addEventListener("storage",function(e){
// Dummy },false);
1、当然可以单独使用第二种方法,测试有效