How to load google plus share button in iframe?

Can someone give me a solution on how to asynchronously load the Google+ share button (and not the +1 button) into an iframe. I did this for the +1 button.

+3
source share
2 answers

Try this html snippet:

<iframe src="https://plusone.google.com/_/+1/fastbutton?bsv&amp;size=medium&amp;hl=en-US&amp;url=http://test.com/&amp;parent=http://test.com/" allowtransparency="true" frameborder="0" scrolling="no" title="+1"></iframe>
+12
source

If what you are trying to do displays the button explicitly when the user points something at something you need to do, use the explicit render stream, as described here:

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, , , , .

+2

All Articles