提问人:Moritz 提问时间:10/30/2023 更新时间:10/30/2023 访问量:20
Mixcloud Widget API:无法在“DOMWindow”上执行“postMessage”
Mixcloud Widget API: Failed to execute 'postMessage' on 'DOMWindow'
问:
在我的网站上,我想嵌入 Mixcloud iframe 播放器并使用 Widget JavaScript API (https://www.mixcloud.com/developers/widget/) 与它进行交互。
我基本上是从文档中复制代码:
<script src="//widget.mixcloud.com/media/js/widgetApi.js" type="text/javascript"></script>
<iframe
id="my-widget-iframe"
src="https://www.mixcloud.com/widget/iframe/?hide_cover=1&mini=1&light=1&hide_artwork=1&autoplay=0&feed=%2Feosradio%2Fani-kvirkvelia-27-may-2022%2F"
width="100%"
height="60"
frameborder="0"
allow="autoplay"
></iframe>
var widget = Mixcloud.PlayerWidget(document.getElementById("my-widget-iframe"));
但是似乎有一些错误似乎阻止了我的 JS 与 Mixcloud 对象的交互。
在 Chrome (v118) 中,没有任何效果,我收到以下错误消息:
widgetApi.js:202 Failed to execute 'postMessage' on 'DOMWindow': The target origin provided ('https://player-widget.mixcloud.com') does not match the recipient window's origin ('http://127.0.0.1:5500').
在Safari(v16)中,消息像这样准备好,但与Mixcloud对象的交互似乎是可能的:
[Error] Unable to post message to https://player-widget.mixcloud.com. Recipient has origin http://127.0.0.1:5500
我在我的本地主机和带有 https 的网站上都尝试过。 我在生产网站上工作了几年(2020 年),最近停止了(2023 年 9 月)。
Mixcloud 改变了什么吗?还是浏览器发生了变化?我能做些什么来解决这个问题? 感谢您的帮助!
答: 暂无答案
评论