Question

Here is how I implement Facebook Feed Dialog to my page:
HTML tag:

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://ogp.me/ns/fb#" xmlns:og="http://opengraphprotocol.org/schema/">

JavaScript:

(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&appId=***************"; 
    fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));

FB.init({
    appId: '***************', 
    display: 'popup',
    status: true, 
    cookie: true, 
    xfbml: true, 
    oauth: true,
    method: 'send'
});

Send button:

<a onclick="javascript:twitter(this); return false;" href="https://www.facebook.com/dialog/feed?display=popup&app_id=***************&name=<name>&link=<link>&redirect_uri=<uri>">
    <div class="fb-container"></div>
</a>

Here I am using Twitter's popup script because display:popup doesn't work, don't know why.

However the popup appears and I send the feed. But then I am redirected to redirect_uri. I don't want this. I just want to close the popup after clicking Send or Cancel button. I tought something like detecting if a button is clicked and then try window.close; but no success because it is a new window (the popup).

Any ideas?

Was it helpful?

Solution

You are currently using the “direct URL” version of the dialog – and that will always redirect.

If you want it in a popup, that will just close itself after use, then call the dialog by using FB.ui, as in the example in the dialog’s documentation: https://developers.facebook.com/docs/reference/dialogs/feed/

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top