Skip to content

[html] 第9天 浏览器内多个标签页之间的通信方式有哪些? #25

Open
@haizhilin2013

Description

@haizhilin2013
Collaborator

第9天 浏览器内多个标签页之间的通信方式有哪些?

Activity

changed the title [-][html] 第9 浏览器内多个标签页之间的通信方式有哪些?[/-] [+][html] 第9天 浏览器内多个标签页之间的通信方式有哪些?[/+] on Apr 24, 2019
github-linong

github-linong commented on May 23, 2019

@github-linong
tiyunchen

tiyunchen commented on Jun 1, 2019

@tiyunchen

PostMessage: 曾经在项目中使用过: 在一个页面内加了一个iframe, 由于父页面要和iframe通信所以使用了这个方式

Damon99999

Damon99999 commented on Jun 18, 2019

@Damon99999

1:本地存储
2:postMessage
如果使用vue框架那么vuex也是ok的

Konata9

Konata9 commented on Jul 24, 2019

@Konata9
  • 借助 cookie, localStorage(sessionStorage 在某些场景下并不能跨标签,必须要原页面的 a 标签的 target=_blank 才行)。这些只要在同一个域名下就可以进行通信和数据的共享
  • 借助 window.postMessage API 来进行消息的传递
xv700

xv700 commented on Jul 26, 2019

@xv700

完全答案
WebSocket (可跨域)
postMessage(可跨域)
Worker之SharedWorker
Server-Sent Events
localStorage
BroadcastChannel
Cookies

https://xv700.gitee.io/message-communication-for-web/

qhdxwdm

qhdxwdm commented on Sep 12, 2019

@qhdxwdm

1.WebSocket (可跨域)
2.postMessage(可跨域)
3.SharedWorker
4.Server-Sent Events
5.localStorage
6.BroadcastChannel IE不支持
7.Cookies

censek

censek commented on Oct 10, 2019

@censek
  • localStorage
  • cookie + setInterval
kruzabc

kruzabc commented on Dec 24, 2019

@kruzabc

不借助服务器支持的话:

  1. 监听storage事件
  2. cookie + setInterval
  3. BroadcastChannel (兼容:chrome 54+ ,firefox:38+, Edge 76 +, safari 13, IE尚不支持)
  4. SharedWorker
blueRoach

blueRoach commented on May 25, 2020

@blueRoach

1.websocket
H5提供的在TCP连接上进行的双向通讯
2.localStorage(sessionStorage是每个标签页独立的)
3.cookie
4.SharedWorker

giggleCYT

giggleCYT commented on Jun 3, 2020

@giggleCYT

websocket协议、
localstorage、
以及使用html5浏览器的新特性SharedWorker

smile-2008

smile-2008 commented on Sep 3, 2020

@smile-2008

完全答案
WebSocket (可跨域)
postMessage(可跨域)
Worker之SharedWorker
Server-Sent Events
localStorage
BroadcastChannel
Cookies

githubzml

githubzml commented on Nov 25, 2020

@githubzml

尝试过的
localStroage
WebScoket

8 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @smile-2008@haizhilin2013@Konata9@buuug7@WangXi01

        Issue actions

          [html] 第9天 浏览器内多个标签页之间的通信方式有哪些? · Issue #25 · haizlin/fe-interview