处理邮政邮政时处理javascript iframe down案例

发布于 2025-01-28 07:47:10 字数 450 浏览 3 评论 0原文

我正在尝试处理 iframe 是我的react js应用程序中的情况下,

我正在对iframe进行postmessages,如this iframe.contentwindow.postmessage(mesage,emort);

有时iframe有时原点可能会出于某些原因,我想处理此部分,在控制台中,我得到这个错误

Failed to execute 'postMessage' on 'DOMWindow': The target origin provided ('localhost') does not match the recipient window's origin ('null').

问题是我该如何捕获它? iframe可以加载,一切都可以了,但是x分钟后,它可以关闭,如何捕获此错误?任何想法都将不胜感激

I am trying to handle iframe is down case on my react js application

I am doing postMessages to the iframe like this iframe.contentWindow.postMessage(mesage, origin);

Sometimes iframe origin can be down , with some reasons , I want to handle this part , in the console , I am get this error

Failed to execute 'postMessage' on 'DOMWindow': The target origin provided ('localhost') does not match the recipient window's origin ('null').

Question is how can I catch it ? Iframe can be load and everything can be fine , but after x minute it can be down , how to catch this error ? any ideas will be appreciated

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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