多页签之间的通信

Posted by Turingdo Studio on February 23, 2021

如何实现浏览器内多个标签页之间的通信?

  • WebSocket
  • SharedWorker
  • BoastcaseChanel
  • localStorge
  • cookie + setInterval
  • postMessage

postMessage()方法允许来自不同源的脚本采用异步方式进行有限的通信,可以实现跨文本档、多窗口、跨域消息传递。 消息发送:otherWindow.postMessage(message, targetOrigin);

浏览器的两个页面之间通信的问题
浏览器窗口之间的通信

DEMO