2017-03-13 15 views
0

所以我一直在尝试使用此代码的YouTube API V3给我加上我的测试网站订阅按钮:添加YouTube订阅按钮在我的网站,但给出了这样的错误

<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

我不知道我做了什么,但突然它的工作!谢谢。 – Ismail