【问题标题】:Google plus badge not showingGoogle+ 徽章未显示
【发布时间】:2014-07-29 07:51:17
【问题描述】:

我在 Google plus 开发人员上创建了一个徽章:https://developers.google.com/+/web/badge/ 但是当我将代码复制并粘贴到我的 HTML 文件中时,徽章没有显示。这是我的代码:

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Google + Badge</title>
  </head>
  <body>

    <!-- Place this tag where you want the widget to render. -->
    <div class="g-page" data-href="https://plus.google.com/109600806421917664383" data-rel="publisher"></div>

    <!-- Place this tag after the last widget tag. -->
    <script type="text/javascript">
      (function() {
        var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
        po.src = 'https://apis.google.com/js/platform.js';
        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
      })();
    </script>


  </body>
</html>

我做错了什么!?谢谢

【问题讨论】:

  • 发布的代码在Fiddle 中似乎运行良好,所以这可能不是问题所在,因此很难判断问题出在哪里,但这可能是您网站上的其他问题。

标签: javascript html google-plus


【解决方案1】:

adeneo's JSFiddle 也不适用于我(Chrome 35、OSX)。首先,我必须在Disconnect extension 中将其列入白名单。然后我收到控制台错误

Uncaught ReferenceError iframes is not defined

根据http://www.jesse-smith.net/fixed-google-plus-1-button-working/Google PlusOne Button has errors on Chrome,这是由于第三方 cookie 被阻止所致。

如果您也在使用 Chrome(并且问题也是由阻止第 3 方 cookie 引起的),那么您的网址栏右侧应该有一个 cookie 图标。点击它,点击“显示 cookie 和其他网站数据...”,切换到“已阻止”标签并允许来自 *.google.com 域的所有第 3 方 cookie。

您也可以进入设置 > 显示高级设置 > 隐私,点击“内容设置”按钮并在任何地方启用 3rd-party cookie。

很遗憾,我无法找到让您的 G+ 按钮在禁用了 3rd-party cookie 的浏览器中工作的方法。

【讨论】:

  • 我也在使用 Chrome,只是在新设置上进行了测试,所有浏览器的默认设置都不会阻止这些 cookie,所以你摆弄了一些 99.99% 的互联网用户不会的设置不要摆弄,你认为这是问题所在?这很可能是 OP 的问题,但从统计数据来看,这种可能性很小。
  • 我不认为这是问题,只是它可能是。根据我在 Google 中的发现,这似乎是一个相当普遍的原因。而且,是的,99.99% 的互联网用户可能从未更改过该设置,但 OP 是一名开发人员,并且可能知道得更清楚。 OP 没有给我们足够的信息来进一步缩小范围,所以这是我能做的最好的。我们不应该这样做吗?帮助中心说在这些情况下给出“部分答案”,所以我认为可以。
  • 不,这里没有反对意见,答案可能很好,只是注意到问题似乎不太可能只是 OP 更改了浏览器中的某些设置而忘记了它,但我真的没有想法,所以再一次,很可能就是这样吗?
猜你喜欢
  • 1970-01-01
  • 2022-11-03
  • 2020-08-05
  • 1970-01-01
  • 2018-04-23
  • 2017-11-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多