Can't see localstorage event across tabs

后端 未结 1 1133
长情又很酷
长情又很酷 2021-01-21 02:17

I\'m trying to create a simple proof-of-concept regarding the use of localStorage to trigger tabs in my application when changes occur. I know this is possible based on other a

1条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-21 02:54

    In order for the window.addEventListener to work on storage:

    1. you MUST access the page using web-server (http://a.b.c.d/ or http://domain)

      • Direct access (using file:/// or c:\file.html will not work.
        (chrome and ie ignore it, firefox and safari can run it anyway).
    2. I would consider also removing the 3rd, it is not relevant to elements in your DOM tree, and it might cause troubles (let the browser have it's defaults).

    This code was tested in Chrome 52, Firefox 47+48, IE 11, Safari 5.7.1

    
    
    
    
      Tab1
    
    
    
      
      
      
    
    
    

    0 讨论(0)
提交回复
热议问题