M
M
Mikhail Guber2015-06-21 00:07:31
Facebook
Mikhail Guber, 2015-06-21 00:07:31

How to remove the Facebook widget when confirming a like?

Hello! There is a Facebook page widget code. Tell me how to remove the widget if the user likes it?

(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/ru_RU/sdk.js#xfbml=1&version=v2.3";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));

<div class="fb-page" data-href="https://www.facebook.com/facebook" data-width="500" data-height="200" data-small-header="false" data-adapt-container-width="true" data-hide-cover="false" data-show-facepile="false" data-show-posts="false"><div class="fb-xfbml-parse-ignore"><blockquote cite="https://www.facebook.com/facebook"><a href="https://www.facebook.com/facebook">Facebook</a></blockquote></div></div>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Tolerant, 2015-06-24
@mres

var page_like_or_unlike_callback = function(url, html_element) {
  console.log("page_like_or_unlike_callback");
  console.log(url);
  console.log(html_element);
}

// In your onload handler
FB.Event.subscribe('edge.create', page_like_or_unlike_callback);
FB.Event.subscribe('edge.remove', page_like_or_unlike_callback);

Tyk
Implementation:
FB.Event.subscribe('edge.create', function(url, html_element) {
   var FBbox = document.querySelectorAll(".fb-page");
   FBbox.style.display = 'none';
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question