user993683
user993683

Reputation:

Manually render dynamically generated Google 'plus one' button

Here's the scene:

I've heard that this might be useful: gapi.plusone.go();

But I'm not sure.

Any ideas?

Thanks

Upvotes: 9

Views: 5459

Answers (1)

mimming
mimming

Reputation: 13954

You're on the right track. gapi.plusone.go() is one way to explicitly render the +1 button. Here's a code snippet from the official docs that illustrates another method using gapi.plusone.render().

<html>
  <head>
    <title>+1 Demo: Explicit render</title>
    <link rel="canonical" href="http://www.example.com" />
    <script type="text/javascript" src="https://apis.google.com/js/plusone.js">
      {"parsetags": "explicit"}
    </script>
    <script type="text/javascript">
      function renderPlusone() {
        gapi.plusone.render("plusone-div");
      }
    </script>
  </head>
  <body>
    <a href="#" onClick="renderPlusone();">Render the +1 button</a>
    <div id="plusone-div"></div>
  </body>
</html>

The JavaScript API is further documented elsewhere on the previously linked page.

Upvotes: 10

Related Questions