术后在浏览器中具有不同的行为

发布于 2025-02-02 15:07:43 字数 599 浏览 2 评论 0原文

我有以下文件:

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文