我想添加一个谷歌+徽章到我的博客。目前,我在我的博客中添加了一个google plus徽章,并尝试通过以下代码添加一个图片:
<div class="g-plus" data-width="208" data-height="69" style="float:left; direction:ltr;text-align:left" data-href="//plus.google.com/116527224364668694256" data-rel="author"></div>
<script type="text/javascript">
(function() {
var po = document.createElement('script');
po.type = 'text/javascript';
po.async = true;
po.src = 'https://apis.google.com/js/plusone.js';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(po, s);
var iab = document.getElementsByClassName("iab")[0];
iab.style.backgroundimage = "url('https://googledrive.com/host/0B7YvaD77pFw9cDczZnBRanFFVWs/img/avatar.jpg')";
})();
</script>
输出是这样的:
我想添加我自己的头像,但它不能正常工作。这段代码有什么问题?最好的解决方法是什么?
发布于 2013-03-05 05:44:12
没有办法在Google+徽章上显示您的头像。此处的文档如下:
https://developers.google.com/+/web/badge/
具有可在徽章上配置的内容的最新信息。高级选项将允许您设置徽章的宽度,它可以显示或多或少的信息,但目前没有一个选项来显示您的头像。
徽章呈现代码将覆盖您在其上设置的任何样式,这就是为什么您的其他设置不会更改徽章的外观。
如果你只想渲染你的头像,你可以使用Google API来实现,如Google API explorer所示:
然后从返回的person对象中检索头像。
https://stackoverflow.com/questions/15172169
复制相似问题