Google+按钮iframe错误

Google+ button iframe error

本文关键字:错误 iframe 按钮 Google+      更新时间:2023-09-26

我正在制作一个生成器,它可以帮助在一个屋檐下创建社交按钮。我能够为Facebook创建生成器。Twitter,但是Google+按钮一开始就有问题。

我搜索了很多,但找不到一个合适的答案"拒绝显示....。'X-Frame-Options'到'SAMEORIGIN'".

Refused to display 'https://apis.google.com/se/0/_/+1/fastbutton?usegapi=1&action=1&size=medium…d=I0_1438276469698&parent=http%3A%2F%2Flocalhost&pfname=&rpctoken=13424874' in a frame because it set 'X-Frame-Options' to 'SAMEORIGIN'.

是的,我在本地测试,但我甚至在一个网站上尝试在线,但它仍然抛出这个错误。

简单代码

jQuery( document ).ready( function( $ ) {
    // GooglePlus script
    (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);
    })();
    // Add button markup
    $( '#googleplus-container' ).html( '<div id="gp" class="g-plusone" data-action="1" data-size="medium" data-annotation="inline" data-width=""></div>' );
    // Initialize button
    if( typeof gapi !== 'undefined' ){
        gapi.plusone.go( '#googleplus-container' );
    }
});

这个问题有什么直接的解决办法吗?

一旦这个问题解决了,我将根据用户输入动态地改变按钮和它的参数,然后将重新初始化按钮,以便可以实时看到更改。

是否有其他的方法,我可以遵循像直接添加iframe?

谢谢!

g-plusonediv中删除data-action="1"。这是一个不支持的属性,并且会以某种方式改变行为。