惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

D
DataBreaches.Net
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
云风的 BLOG
云风的 BLOG
B
Blog
博客园 - Franky
I
InfoQ
A
About on SuperTechFans
博客园_首页
L
LangChain Blog
量子位
腾讯CDC
Microsoft Security Blog
Microsoft Security Blog
博客园 - 【当耐特】
美团技术团队
V
V2EX
Apple Machine Learning Research
Apple Machine Learning Research
雷峰网
雷峰网
MongoDB | Blog
MongoDB | Blog
Microsoft Azure Blog
Microsoft Azure Blog
月光博客
月光博客
T
The Blog of Author Tim Ferriss
P
Proofpoint News Feed
G
Google Developers Blog
Last Week in AI
Last Week in AI

时间的朋友

Windows 命令行密码重置 Anaconda安装 typescript 注解解读1 Konvajs Shape加载自定义图片 sshpass 使用 why-is-node-running webgl笔记 SharedArrayBuffer is not defined blender 常用快捷键 | 时间的朋友 vue -- v3.4commit提交记录2 vue2 升级vue3报错问题整理 着色器 expressjs 源码 hyper-V arch linux 网络配置 element input数字格式化 three 拼接货架 WebAudio笔记 Windows nginx重启bat脚本 vue -- v3.4commit提交记录 URI malformed vue3 -- Class 对象在组件中使用范例 | 时间的朋友 ruby 安装和升级 element-plus 老版本cascader使用卡死问题 vue3 内置Transition组件 | 时间的朋友 前端memo的实现 | 时间的朋友 Vue -- vue-class-component源码 | 时间的朋友 linux 优化脚本 typescript 装饰器 | 时间的朋友 microbundle 源码 | 时间的朋友 WSL2问题解决WslRegisterDistribution failed with error: 0x800701bc
原生跨页面通信方案 | 时间的朋友
2021-05-16 · via 时间的朋友

原生跨页面通信方案

Published: · LastMod: June 20, 2022 · 384 words

原生跨页面通信api 🔗

各API实现跨页面的优缺点:

  • Broadcast Channel:实时通信,随时关闭频道,功能全面;浏览器支持效果不好(IE-都不支持,chrome-54)
  • storageEvent:浏览器支持效果好、API直观。部分浏览器隐身模式下,无法设置localStorage(如safari)。可能因LocalStorage清理不及时而引起问题
  • shareworker:异步处理,不占用主线程,不用 ie 浏览器的话,还是非常推荐的(IE-都不支持)
  • serviceworker:浏览器支持度不高,开启service worker可能会导致浏览器的缓存数据大大增加(IE-都不支持)
  • window.open + window.opener:实现方式不优雅,无法形成统一的解决方案,且在强制刷新页面后会失去关联导致无法通信;实现简单,浏览器兼容性好
  • postMessage:点对点通信,局限性比较大,可扩展性比较差。