在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
?
10 回答11.3k 阅读
5 回答4.9k 阅读✓ 已解决
4 回答3.2k 阅读✓ 已解决
2 回答2.8k 阅读✓ 已解决
3 回答1.5k 阅读✓ 已解决
3 回答2.4k 阅读✓ 已解决
3 回答2.2k 阅读✓ 已解决
一定是发送了两次postMessage,仔细检查一下