谁能给我一个解决方案,我如何加载谷歌加分享按钮(而不是+1按钮)在一个iframe异步。我已经设法为+1按钮做到了这一点。
发布于 2013-04-30 00:58:46
试试下面这段html代码:
<iframe src="https://plusone.google.com/_/+1/fastbutton?bsv&size=medium&hl=en-US&url=http://test.com/&parent=http://test.com/" allowtransparency="true" frameborder="0" scrolling="no" title="+1"></iframe>
发布于 2012-11-27 05:15:41
如果您要做的是在用户将鼠标悬停在某物上时显式呈现按钮,则需要使用显式呈现流,如下所述:
https://developers.google.com/+/plugins/+1button/
但是,有一个问题,因为您使用的是一个共享按钮,所以不能使用显式的呈现代码直接呈现到div。相反,您将创建共享链接,将渲染设置为显式,然后可以使用JavaScript触发共享按钮的渲染。
相关代码为:
<html>
<head>
<title>+Share: Explicit render</title>
<link rel="canonical" href="http://www.example.com" />
<script type="text/javascript">
window.___gcfg = {
lang: 'en-US',
parsetags: 'explicit'
};
function renderShare() {
gapi.plus.go(); // Render all the buttons
}
</script>
</head>
<body>
<a href="#" onClick="renderShare();">Render the share control</a>
<!-- a share button that will get rendered when gapi.plus.go is called -->
<div class="g-plus" data-action="share" id="share-div"></div>
</body>
<script type="text/javascript">
// Asynchronously load the plusone script, for performance
(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);
})();
</script>
</html>
对于您来说,我猜您正在尝试使用不同的触发器来呈现+1按钮,而不是用户显式单击的按钮,您可以只使用适当的事件来触发呈现。
https://stackoverflow.com/questions/10680969
复制相似问题