Youtube API 错误 - 无法在“DOMWindow”上执行“postMessage”:

Posted

技术标签:

【中文标题】Youtube API 错误 - 无法在“DOMWindow”上执行“postMessage”:【英文标题】:Youtube API error - Failed to execute 'postMessage' on 'DOMWindow': 【发布时间】:2018-11-24 05:34:13 【问题描述】:

在“DOMWindow”上执行“postMessage”失败:提供的目标源(“https://www.youtube.com”)与接收窗口的源(“https://my-site.ru”)不匹配。

nginx 在服务器上。当然还有https!

但是我收到了这个错误...只有在 Google Chrome 视频没有启动时,Firefox 显示正常(和 Edge)!

【问题讨论】:

【参考方案1】:

哇,奇怪的错误,“可见性=隐藏”是一个原因。 确保在启动播放器之前显示播放容器(与其父容器一样)。

【讨论】:

我对此充满希望,但我仍然收到Failed to execute 'postMessage' on 'DOMWindow': The target origin provided ('<URL>') does not match the recipient window's origin ('<URL>'). 这没有帮助,因为我们的元素一开始就没有被隐藏、不可见或不透明;)【参考方案2】:

我们在 visibility = hidden 时遇到了同样的问题,我们能够通过使用 CSS opacity 0 实现几乎相同的技巧。

【讨论】:

以上是关于Youtube API 错误 - 无法在“DOMWindow”上执行“postMessage”:的主要内容,如果未能解决你的问题,请参考以下文章

YouTube API 错误,Node.js

无法在 google api youtube 中授权,如何解决? [关闭]

YouTube 数据 API 返回“访问未配置”错误,尽管它已启用

使用 Youtube API 在网络服务器上显示视频时如何修复播放 ID 错误?

通过 Youtube 上传,通过 api 设置为私有(锁定)

YouTube Android Player API无法在xiaomi Redmi Note 3中使用