术后在浏览器中具有不同的行为
我有以下文件:
a.html
<p id="p1">a.html</p>
<iframe src="b.html"></iframe> <!-- we have a realm here -->
<script>
frames[0].postMessage("some data", "*");
</script>
b.html
<p id="p1">b.html</p>
<script>
window.addEventListener("message", (event) => {
console.log("event:", event);
});
</script>
在Google Chrome中,我看不到console.log
来自的消息b.html
(我知道我应该为此切换控制台选项卡),在Firefox的同一刻,我看到了消息。怎么了?
I have the following files:
a.html
<p id="p1">a.html</p>
<iframe src="b.html"></iframe> <!-- we have a realm here -->
<script>
frames[0].postMessage("some data", "*");
</script>
b.html
<p id="p1">b.html</p>
<script>
window.addEventListener("message", (event) => {
console.log("event:", event);
});
</script>
In the google chrome I don't see console.log
message from b.html
(I know what I should switch console tab for that), in the same moment in the firefox I see message. What's the matter?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论