所以我一直在尝试使用YouTube API V3给我的代码在我的测试网站上添加订阅按钮:
<script src="https://apis.google.com/js/platform.js"></script>
<div class="g-ytsubscribe" data-channelid="UCzfStpfCASIjJNK2xMNdJiw" data-layout="full" data-count="default"></div>
但是当我加载页面时,它会给我这些错误:
> Failed to execute 'postMessage' on 'DOMWindow': The target origin
> provided ('file://') does not match the recipient window's origin
> ('null'). cb=gapi.loaded 0:49
> Failed to execute 'postMessage' on 'DOMWindow': The target origin
> provided ('file://') does not match the recipient window's origin
> ('null'). cb=gapi.loaded 0:48
任何帮助将不胜感激!
答案 0 :(得分:0)
刚测试了你的代码片段,并且对我来说很好。我所做的就是把它换成我的测试,它仍然有用 我猜想你的代码存在冲突。 因此,首先尝试将脚本标记置于顶部。如果这不起作用,请尝试取消激活其他脚本以查看哪些脚本存在冲突。