在ifram B中想向iframe B发送消息(页面初始化时执行):
frameA.postMessage('hello', '*')
在iframe A中的事件处理如下:
window.onmessage = function (e) {
console.log(e.data);
};
但是为什么会打印两次hello
?
在ifram B中想向iframe B发送消息(页面初始化时执行):
frameA.postMessage('hello', '*')
在iframe A中的事件处理如下:
window.onmessage = function (e) {
console.log(e.data);
};
但是为什么会打印两次hello
?
13 回答12.6k 阅读
7 回答1.8k 阅读
5 回答1.3k 阅读
3 回答1k 阅读✓ 已解决
3 回答1.2k 阅读✓ 已解决
2 回答1.1k 阅读✓ 已解决
5 回答2.2k 阅读
一定是发送了两次postMessage,仔细检查一下