Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

facebook share HTML5 TypeError: getComputedStyle(...) is null

I'm trying to add facebook share to a page. My issue is with multiple share buttons, first works well but others aren't shown in the page. A note, first share button is visible but others are in a container with display:none css applied.

I have this code in top of the page (I changed facebook app Id to FacebookAppID):

<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 = "//connect.facebook.net/es_ES/all.js#xfbml=1&appId=FacebookAppID";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>

It is each share div in the page:

<div class="fb-share-button" data-href="@url" data-type="button_count" data-width="450"></div>

This issue can be reproduced in IE.

Thanks

like image 616
Daniel Avatar asked Mar 18 '14 16:03

Daniel


1 Answers

The display:none is what is causing the problem

You will need to hide it using opacity, height, and overflow

.fb-share-button { opacity: 0; height: 0px; overflow: hidden; }

and to show it (height can obviously be changed to whatever you like

.showfb.fb-share-button { opacity: 1.0; height: 21px; overflow: visible; }
like image 118
user3704582 Avatar answered Sep 19 '22 19:09

user3704582