I am trying to redirect to an URL if the Facebook Like button has been pressed, but it doesn't work, and results having an error in the source view saying "FB is not defined"
Here's my redirect code:
FB.Event.subscribe('edge.create',
function(response) {
location.href = 'censored';
}
);
and here's the FB like 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>
Anyone help please? I am a noob sorry.
Ensure your FB.Event is inside of the fbAsyncInit function so you assured that the JS SDK framework has been loaded into the browser. Also be sure to call FB.init() first before calling FB.Event.
window.fbAsyncInit=function() {
// YOUR CODE HERE THAT USES FB.anythin
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With