当前位置: 首页 > news >正文

酒店网站规划建设方案书刷关键词排名软件有用吗

酒店网站规划建设方案书,刷关键词排名软件有用吗,企业网站帮助中心,下沙做网站BroadcastChannel与MessageChannel BroadcastChannel BroadcastChannel以广播的形式进行通信 BroadcastChannel用于创建浏览器标签页之间的通信 使用BroadcastChannel的浏览器标签页面必须要遵循同源策略 页面1使用BroadcastChannel创建一个频道,页面2使用Broadc…

BroadcastChannel与MessageChannel

BroadcastChannel

BroadcastChannel以广播的形式进行通信
BroadcastChannel用于创建浏览器标签页之间的通信
使用BroadcastChannel的浏览器标签页面必须要遵循同源策略

页面1使用BroadcastChannel创建一个频道,页面2使用BroadcastChannel链接频道,页面1与页面2即可通信。

let m1=new BroadcastChannel("channel");//入参是创建或链接的频道名,没有频道则创建通信频道,有频道则进入频道
m1.postMessage('data数据');//以广播的形式向其他链接频道的标签发送消息
m1.onmessage=(e)=>{console.log(e);//接收频道发送过来的消息
}

实例

//BroadcastChannel1.html
<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Document</title>
</head>
<body><a href="http://127.0.0.1:8080/BroadcastChannel2.html" target="_blank">打开新的标签页</a><button onclick="send()">点击</button><script>const m1=new BroadcastChannel('one');function send(){m1.postMessage({data:"123123"})}m1.onmessage=(e)=>{console.log('e=>',e);}</script>
</body>
</html>//BroadcastChannel2.html
<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Document</title>
</head>
<body><script>const m1=new BroadcastChannel('one');m1.onmessage=(e)=>{console.log("e=>",e)}m1.postMessage('adad')</script>
</body>
</html>

MessageChannel

MessageChannel以通道的形式进行传值
MessageChannel无法跨越浏览器标签页通信,只能在当前标签页进行通信

MessageChannel的对象只有两个端口:prot1、port2
在这里插入图片描述

let m=new MessageChannel();//创建消息通道
//m有两个端口:prot1、prot2
m.port1.postMessage("data数据");//prot1数据肯定是向prot2发送,同理prot2也只能向prot1发送数据
m.prot2.onmessage=(e)=>{console.log(e);//prot2接收prot1发送的数据
}

实例

<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Document</title>
</head>
<body><script>let m=new MessageChannel();m.port1.postMessage("data");m.port2.onmessage=(e)=>{console.log(e);}</script>
</body>
</html>

Tips:使用MessageChannel传递的引用数据类型是深拷贝。也就是改变端口数据的值,发送端的数据不会改变。

http://www.15wanjia.com/news/35872.html

相关文章:

  • 网站首页插入视频线上推广是什么意思
  • 如果自己想建设网站该怎么做今日郑州头条最新新闻
  • 深圳电子商务网站有哪些安徽seo网络推广
  • 17网站一起做网店好不好百度指数分析
  • 一个网站是如何知道是谁来访问网络软营销
  • 北京营销型网站建设公司最新seo自动优化软件
  • 企业网站优化操作疫情排行榜最新消息
  • 做网站的工资深圳市前十的互联网推广公司
  • 新手学做网站12天婴山东免费网络推广工具
  • 正规网站建设定制百度题库
  • 河东集团网站建设免费b站软件下载
  • 网站建设设计百度知道网页版登录入口
  • 专门做眼镜的国外网站口碑营销案例分析
  • 小红门网站建设如何做营销策划方案
  • 网站前端设计理念百度页面
  • 怎么做网站后台操作日志推广员是干什么的
  • 哪个网站做图文素材多关键词热度
  • 微软做网站的软件外贸平台有哪些比较好
  • 庆阳房屋买卖网南宁百度推广seo
  • 做网站是买服务器还是买主机seo优化6个实用技巧
  • 做网站去哪里找app推广渠道
  • 网站更新维护怎么做如何推广一个项目
  • 织梦网站定时提交链接
  • 在哪网站可以做农信社模拟试卷ttkefu在线客服系统官网
  • 安徽省市政府部门网站建设要求中国制造网网站类型
  • 兰州网站建设尚美网站推广的方式有哪些
  • 网站的建设 教学计划十大微商推广平台
  • 吉林做网站哪家好外贸谷歌推广怎么样
  • 衡水做网站建设自己开平台怎么弄啊
  • 网站怎么运营推广百度关键词的费用是多少