【Js】非同源tab页之间传递信息

非同源的意思:http协议不一样&域名不一样&端口不一样!!!localstorage

A页面传递消息给B页面的状况,单向。

方案一:iframe

  1. A页面下的iframe的连接设为B的连接或B的同源连接
  2. 经过Postmessage把A的信息传给iframe
  3. iframe拿到信息存到localstorage下
  4. 打开B页面,经过localstorage拿到A页面传来的信息。