localStorage in win8.1 IE11 does not synchronize

前端 未结 4 1206
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-30 05:41

We have two pages \"/read\" and \"/write\". Page \"/write\" each second updates localStorage with current time:

setInterval(function(){
    var time = (new          


        
4条回答
  •  独厮守ぢ
    2020-12-30 06:15

    It seems that the localStorage.GetItem method under IE11 / Windows 8 is unreliable and may retrieve previous values. But this can be worked around by calling the localStorage.SetItem method immediately before retrieving a value.

    I managed to replicate the issue using muttonUp's code and then made the following change to get the two windows talking to each other:

    
    
        LocalStorage Test
    
    
    
    
    
    
    
    

    Here's the output:

    This workaround is useful in my scenario as I'm only retrieving values from localStorage at infrequent intervals and only storing small amounts of data. Because of the possible performance overhead with the increased number of setItem method calls I'd likely think carefully before using this workaround where the traffic to and from localStorage is heavier.

提交回复
热议问题