【问题标题】:Youtube subscribe button not showingYoutube 订阅按钮未显示
【发布时间】:2016-11-05 09:11:04
【问题描述】:

我试图在 localhost 中包含一个 YouTube 订阅按钮,但它似乎不起作用,而在 JSfiddle 中它工作得非常好。难道我做错了什么?我正在使用来自https://developers.google.com/youtube/youtube_subscribe_button的代码

我在本地主机上的代码:

<!DOCTYPE html>
<html>
<head>
    <title>Testing a YouTube button</title>
    <script src="https://apis.google.com/js/platform.js"></script>
</head>
<body>
    <div class="g-ytsubscribe" data-channelid="UCWTfbcQsyNLv1ZLsZrhVW2w" data-layout="full" data-count="default"></div>
</body>
</html>

JSFiddle example

谢谢!

【问题讨论】:

    标签: javascript html youtube platform


    【解决方案1】:

    当我在http://localhost 上测试它时它工作正常,但当我使用file:// URL 测试它时它失败了。

    控制台报告:

    cb=gapi.loaded_0:45 无法在“DOMWindow”上执行“postMessage”:提供的目标源(“file://”)与接收窗口的源(“null”)不匹配。

    该脚本仅在您加载 HTTP(S) 网页时有效。不要尝试在file: URL 上使用它(并始终查看控制台以获取错误消息!)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-07-02
      • 2017-11-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-06-07
      相关资源
      最近更新 更多