window.addEventlistener('storage',function(event){
console.log(event)
})
//event 部分字段
{
key: 'key1', //变动的key
oldValue: '1', //变动之前的值
newValue: '2', //变动之后的值
url: ''http://xxxxxx", //变动来着那个页面
}
// 省略了很多字段
storage事件的触发满足两个条件:
1.监听与触发事件发生在两个页面(两个window)
2.两个页面同源