web storage

window.addEventlistener('storage',function(event){
  console.log(event)
})

//event 部分字段
{   key: 'key1', //变动的key   oldValue: '1', //变动之前的值   newValue: '2', //变动之后的值   url: ''http://xxxxxx", //变动来着那个页面 }
// 省略了很多字段

storage事件的触发满足两个条件:

1.监听与触发事件发生在两个页面(两个window)

2.两个页面同源

posted @ 2019-02-20 15:53  websjs  阅读(199)  评论(0编辑  收藏  举报