FB not defined

I am trying to redirect the url if the Facebook Like button is clicked, but it does not work, and the results have an error in the original view, which says: "FB is not defined"

Here is my redirect code:

FB.Event.subscribe('edge.create', function(response) { location.href = 'censored'; } ); 

and here the FB button is like a button

  <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/en_US/all.js#xfbml=1"; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk')); </script> <center><fb:like href="http://www.siriforall.net" send="true" width="450" show_faces="false"></fb:like></center> 

Can anybody help? I'm sorry, I'm sorry.

+4
source share
1 answer

Make sure your FB.Event is inside the fbAsyncInit function, so you are assured that the JS SDK infrastructure is loaded into the browser. Also, before calling FB.Event, be sure to call FB.init ().

 window.fbAsyncInit=function() { // YOUR CODE HERE THAT USES FB.anythin } 
+12
source

Source: https://habr.com/ru/post/1393172/


All Articles