【问题标题】:Adding a YouTube subscribe button in my website but gives this error在我的网站中添加 YouTube 订阅按钮,但出现此错误
【发布时间】:2017-08-03 07:22:22
【问题描述】:

所以我一直在尝试使用 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

任何帮助将不胜感激!

【问题讨论】:

    标签: javascript jquery youtube youtube-data-api


    【解决方案1】:

    刚刚测试了你的 sn-p,对我来说效果很好。我所做的只是将你的换成我的进行测试,它仍然有效。
    我猜你的代码有冲突。 因此,请尝试将您的脚本标签作为第一次调用放在顶部。如果这不起作用,请尝试停用其他脚本以查看哪些脚本存在冲突。

    【讨论】:

    • 我不知道我做了什么,但突然它起作用了!不过谢谢。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-07-14
    • 2017-11-15
    • 2012-07-02
    • 1970-01-01
    相关资源
    最近更新 更多