首页 > 解决方案 > 如何处理 postMessage 错误:无法在“DOMWindow”上执行“postMessage”?

问题描述

我在尝试让我的页面在 iFrame 上可用时遇到问题,当它作为 iFrame 包含在另一个页面中时,我收到以下消息:

'未能在'DOMWindow'上执行'postMessage':提供的目标来源(' https://undefined ')与收件人窗口的来源(' https://parent.com.br ')不匹配。

起源确实不同,但与其他帖子不同我的帖子在消息中变得“未定义”。

iFrame如下:

<iframe src="https://mypage/details" 
            sandbox=" allow-top-navigation-by-user-activation allow-popups-to-escape-sandbox allow-presentation allow-scripts allow-top-navigation allow-forms allow-modals 
allow-pointer-lock allow-popups  allow-scripts allow-top-navigation" height="646px" width="100%">
</iframe>

为了能够将其放在 iFrame 上,我应该在我的页面中做些什么吗?

我的页面由 angular-8 应用程序提供。

谢谢

标签: angulariframepostmessage

解决方案


推荐阅读