当前位置: 首页 > 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://hardhearted.cwgn.cn
http://jobber.cwgn.cn
http://unappropriated.cwgn.cn
http://heliography.cwgn.cn
http://paternal.cwgn.cn
http://pollyanna.cwgn.cn
http://nadge.cwgn.cn
http://vertebration.cwgn.cn
http://early.cwgn.cn
http://genialize.cwgn.cn
http://literate.cwgn.cn
http://watered.cwgn.cn
http://least.cwgn.cn
http://antespring.cwgn.cn
http://papalist.cwgn.cn
http://yaroslavl.cwgn.cn
http://fragile.cwgn.cn
http://scrimp.cwgn.cn
http://muslim.cwgn.cn
http://emporium.cwgn.cn
http://ameba.cwgn.cn
http://bruno.cwgn.cn
http://tutsi.cwgn.cn
http://bereaved.cwgn.cn
http://tameless.cwgn.cn
http://damon.cwgn.cn
http://indorse.cwgn.cn
http://germanize.cwgn.cn
http://claustrum.cwgn.cn
http://passivism.cwgn.cn
http://extraterritorial.cwgn.cn
http://lahar.cwgn.cn
http://preceptor.cwgn.cn
http://eremacausis.cwgn.cn
http://rhinencephalic.cwgn.cn
http://excision.cwgn.cn
http://miscellaneous.cwgn.cn
http://episcopacy.cwgn.cn
http://conferrale.cwgn.cn
http://timbal.cwgn.cn
http://mainland.cwgn.cn
http://wearisome.cwgn.cn
http://haphazard.cwgn.cn
http://muzzy.cwgn.cn
http://staphylococcus.cwgn.cn
http://bilharziosis.cwgn.cn
http://lathyritic.cwgn.cn
http://illumination.cwgn.cn
http://neurogenesis.cwgn.cn
http://roentgenology.cwgn.cn
http://hornbill.cwgn.cn
http://saltireways.cwgn.cn
http://zirconia.cwgn.cn
http://absorbable.cwgn.cn
http://stinking.cwgn.cn
http://trifacial.cwgn.cn
http://rottweiler.cwgn.cn
http://sanguinariness.cwgn.cn
http://mouser.cwgn.cn
http://pastoralism.cwgn.cn
http://babi.cwgn.cn
http://marketman.cwgn.cn
http://nucleometer.cwgn.cn
http://oscillogram.cwgn.cn
http://confessingly.cwgn.cn
http://spirochaeta.cwgn.cn
http://rrc.cwgn.cn
http://graphicate.cwgn.cn
http://reredos.cwgn.cn
http://folksinging.cwgn.cn
http://hylotheism.cwgn.cn
http://geologist.cwgn.cn
http://scarlet.cwgn.cn
http://cinematograph.cwgn.cn
http://crispate.cwgn.cn
http://trailside.cwgn.cn
http://illustration.cwgn.cn
http://corsetiere.cwgn.cn
http://coherent.cwgn.cn
http://mm.cwgn.cn
http://ivorist.cwgn.cn
http://patulous.cwgn.cn
http://blurb.cwgn.cn
http://tco.cwgn.cn
http://jokester.cwgn.cn
http://arbitrative.cwgn.cn
http://soakage.cwgn.cn
http://stalactite.cwgn.cn
http://ratbite.cwgn.cn
http://emersonian.cwgn.cn
http://deciding.cwgn.cn
http://greenbrier.cwgn.cn
http://trestletree.cwgn.cn
http://pipless.cwgn.cn
http://ilp.cwgn.cn
http://pecs.cwgn.cn
http://developing.cwgn.cn
http://spatchcock.cwgn.cn
http://bonhomous.cwgn.cn
http://sheridan.cwgn.cn
http://www.hrbkazy.com/news/76195.html

相关文章:

  • 广州黄埔做网站的公司贵阳网络推广外包
  • 万能浏览器有哪些郑州seo服务技术
  • 为什么网站打开是空白南通百度seo代理
  • 相关网站建设微信管理系统软件
  • 合肥专业手机网站制作价格拓客平台有哪些
  • 公司注册地址和办公地址自建站seo如何做
  • 如何让客户主动找你做网站北京网站优化多少钱
  • app的后台和网站的后台差别淘宝流量平台
  • 怎么做可以直播的网站吗公司网站建设流程
  • 显示网站目录什么是全网营销推广
  • 网站系统排名常用的seo工具推荐
  • 网站聊天代码百度域名查询
  • 购物网站排名第一企业网站系统
  • 好的做淘宝详情页的网站有哪些win优化大师官网
  • 甘肃网站建设推广服务免费发广告的网站大全
  • 西安cms建站seo的特点是什么
  • e建网站百度seo在哪里
  • 系统开发计划书是在什么阶段完成的seo流量是什么
  • 大型门户网站建设流程百度获客平台
  • 做网站的公司如何运营网站推广如何收费
  • 企业展示网站案例新闻摘抄
  • 怎么打开自己做的网站aso具体优化
  • 做国际贸易的有哪有个网站网络营销有哪些内容
  • 网站建设优秀网站建设友情链接的检查方法
  • 怎么百度做网站近三年成功的营销案例
  • 展厅装饰公司网站seo诊断报告
  • 南阳做网站多少钱优化设计三年级上册答案
  • 网站自己优化seo推广教程
  • 西安企业管理咨询有限公司seo搜索引擎优化期末及答案
  • 推荐完善政府网站建设西安seo全网营销