I have a facebook tab with an iframe application and within that tab there is a facebook like button to have a second capability to like the facebook page. It is an ordinary facebook like button iframe.
Is there a possibility to redirect the user when it clicks the button? I tried it the following code:
<div id="fb-root"></div>
<script type="text/javascript">
window.fbAsyncInit = function() {
FB.init({appId: '<my app id>', status: true, cookie: true, xfbml: true});
FB.Canvas.setSize({ width: 520, height: 1500 });
FB.Event.subscribe('edge.create',
function(response) {
alert('like!');
}
);
};
//Load the SDK asynchronously
(function() {
var e = document.createElement('script'); e.async = true;
e.src = document.location.protocol +
'//connect.facebook/en_US/all.js';
document.getElementById('fb-root').appendChild(e);
}());
</script>
But this doesn't work. Is there a way or am I doing something wrong?
I have a facebook tab with an iframe application and within that tab there is a facebook like button to have a second capability to like the facebook page. It is an ordinary facebook like button iframe.
Is there a possibility to redirect the user when it clicks the button? I tried it the following code:
<div id="fb-root"></div>
<script type="text/javascript">
window.fbAsyncInit = function() {
FB.init({appId: '<my app id>', status: true, cookie: true, xfbml: true});
FB.Canvas.setSize({ width: 520, height: 1500 });
FB.Event.subscribe('edge.create',
function(response) {
alert('like!');
}
);
};
//Load the SDK asynchronously
(function() {
var e = document.createElement('script'); e.async = true;
e.src = document.location.protocol +
'//connect.facebook/en_US/all.js';
document.getElementById('fb-root').appendChild(e);
}());
</script>
But this doesn't work. Is there a way or am I doing something wrong?
Share Improve this question edited Aug 3, 2011 at 17:07 stofl asked Aug 3, 2011 at 9:31 stoflstofl 2,9827 gold badges37 silver badges49 bronze badges 2- Is the like button functioning properly on its own? – jBit Commented Aug 3, 2011 at 9:52
- possible duplicate of How can I redirect once facebook like button is clicked? – ifaour Commented Aug 3, 2011 at 11:02
1 Answer
Reset to default 1I just tested the following code and it works as expected
<html xmlns="http://www.w3/1999/xhtml" xmlns:fb="http://www.facebook./2008/fbml">
<head></head>
<body>
<div id="fb-root"></div>
<fb:like href="http://yoururlto.like" send="false" width="450" show_faces="false" font=""></fb:like>
<script type="text/javascript">
window.fbAsyncInit = function() {
FB.init({appId: 'YOUR_APP_ID', status: true, cookie: true, xfbml: true});
FB.Canvas.setSize({ width: 520, height: 1500 });
FB.Event.subscribe('edge.create',
function(response) {
alert('like!');
// put redirect code here eg
window.location = "http://www.mysite./redirected.html";
}
);
};
//Load the SDK asynchronously
(function() {
var e = document.createElement('script'); e.async = true;
e.src = document.location.protocol +
'//connect.facebook/en_US/all.js';
document.getElementById('fb-root').appendChild(e);
}());
</script>
</body>
</html>
How does it pare to your own page?
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745591314a4634849.html
评论列表(0条)