iframe中的Google+和评论对话框
问题描述:
我在页面的iframe中有一个Google+快速按钮。当按钮处于悬停状态时,将显示“公开推荐为...”弹出窗口,但由于该按钮位于iframe的右边缘,所以弹出窗口被切断。我想强制弹出窗口显示在Google+按钮的左侧,但我没有看到关于如何操作的任何信息,或者甚至可以完成。这可能吗?iframe中的Google+和评论对话框
这里是我的代码:
MYDOMAIN1.COM/parentpage.html:
<html>
<head></head>
<body>
<div class="content">
<iframe src="http://mydomain2.com/myiframe.html"></iframe>
</div>
<div class="sidebar">
....
</div>
</body>
</html>
MYDOMAIN2.COM/myiframe.html:
<html>
<head></head>
<body>
<iframe src="https://plusone.google.com/_/+1/fastbutton?usegapi=1
&bsv=o&size=tall&count=true&align=left&hl=en-US
&origin=http%3A%2F%2Fwww.mydomain1.com
&url=http%3A%2F%2Fwww.mydomain1.com%2Fmypage%2F
&parent=http%3A%2F%2Fwww.mydomain1.com" id="I0_1234567890123"
name="I0_1234567890123" allowtransparency="true" frameborder="0"
scrolling="no" data-gapiattached="true" title="+1">
</iframe>
</body>
</html>
页面上MYDOMAIN1.COM是一个Wordpress PHP页面。 MYDOMAIN2.COM中的iframe内容是一个ASP应用程序 - 因此是分离的。
答
https://plusone.google.com/_/+1/fastbutton?...
不是公共API,你不应该直接使用它。相反,使用支持参数documented +1 button的参数,您可以将气泡定位到所需的方向。
<html>
<head></head>
<body>
<!-- Place this tag where you want the +1 button to render. -->
<div class="g-plusone" data-annotation="inline" data-width="300" data-href="http://example.com" expandTo="bottom" ></div>
<!-- Place this tag after the last +1 button 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>
亚伯拉罕,出城。回过头来,在你的答案中加入了示例代码,但没有任何出现,并且没有明显的错误。这被加载到一个Wordpress页面。我尝试在'(function()'前面加上'$',这没有什么区别。你有什么想法会导致Google+按钮不出现? – rwkiii
abraham,我尝试了包含按钮的方法而且工作得很好,我不太了解这些差异,但我已经测试过了,一切都很好,谢谢你的回答。 –
rwkiii