javascript - iframe 上的 postMessage 调用序列
问题描述
在我的主文档中,我有函数 showOnMap,它通过几个 postMessage 方法与内部 iframe 进行通信。然后我被要求在第一个完成后才调用第二个 postMessage。是否有可能做到这一点?我无法控制 iframe 本身,它来自外部来源。我当前的代码:
function showOnMap(record: ITableData) {
const frame = document.querySelector('iframe') as HTMLIFrameElement;
if (frame && frame.contentWindow) {
frame.contentWindow.postMessage(getFirstMessage(record), '*');
frame.contentWindow.postMessage(getSecondMessage([record]), '*');
}
}
解决方案
推荐阅读
- woocommerce - 为收到的 woocommerce 电子邮件订单添加具有 ACF 值的占位符
- flutter - Flutter - 在 GridView 中禁用滚动,直到孩子填满高度
- android - 使用 firebase 分析,记录和查看个人用户上次登录时间
- r - 将数据拆分为按标签分层的训练和测试
- spring-webflux - 使用 Flux.merge() 的竞争条件
- python - 如何在python中使来自多个页面的抓取数据数组长度相同?
- javascript - 如何在Javascript中删除父级中重复的childNode元素?
- c - 指针之间的类型转换。打印错误
- javascript - 如何使用动态 HTML(Python)从网页中抓取数据?
- c# - 通过 web api ASP.NET 框架 Web 应用程序 c# 将图像/文件上传到 blob azure