在ifram B中想向iframe B发送消息(页面初始化时执行):
frameA.postMessage('hello', '*')
在iframe A中的事件处理如下:
window.onmessage = function (e) {
console.log(e.data);
};
但是为什么会打印两次hello?
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
一定是发送了两次postMessage,仔细检查一下