Skip to content Skip to sidebar Skip to footer

Social Media Buttons Inside Hidden Div

Has anybody been able to get the Facebook Like, Twitter Follow, and Google +1 buttons to work inside a chrome extension. I can get the buttons to show up, and some functionality, b

Solution 1:

They do work in an extension page. You have to explicitly specify a public URL and facebook/twitter have to be modified to explicitly include the protocol. //platform.twitter.com to https://platform.twitter.com

popup.html

<html>
<body>
  <a href="https://twitter.com/twitter" class="twitter-follow-button" data-show-count="false">Follow @twitter</a>
  <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="https://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>

  <div id="fb-root"></div>
  <script>(function(d, s, id) {
    var js, fjs = d.getElementsByTagName(s)[0];
    if (d.getElementById(id)) return;
    js = d.createElement(s); js.id = id;
    js.src = "https://connect.facebook.net/en_US/all.js#xfbml=1&appId=113869198637480";
    fjs.parentNode.insertBefore(js, fjs);
  }(document, 'script', 'facebook-jssdk'));</script>
  <div class="fb-like" data-href="http://example.com" data-send="false" data-layout="button_count" data-width="250" data-show-faces="false"></div>

  <script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script>
  <g:plusone href='http://example.com'></g:plusone>
</body>
</html>

manifest.json

{
  "name": "test",
  "version": "1",
  "browser_action": {
    "default_popup": "popup.html"
  }
}

Solution 2:

Problem solved. I added the markup to the markup page and made an anonymous function call to the API script immediately after the slideToggle began. Works perfect.


Post a Comment for "Social Media Buttons Inside Hidden Div"