user4157770
user4157770

Reputation:

facebook share dialog redirecting instead of popping up?

I have a dynamically generated facebook share button link being generated in JS, here is the url of the button:

https://www.facebook.com/dialog/share?app_id=someAppId&display=popup&href=' + window.location.href;

That all works fine.

My issue is that the "display=popup" parameter in the links query string does not do as it says, instead it redirects to a sharing page when I expect it to popup.

What's more, when I submit the share, I do not get redirected back to my site.

I am new to the facebook sharing SDK and to be honest am getting quite stressed with it.

All I want is a simple share button (I made a custom styled button which is why I use a dynamically generated HREF) that doesn't mess with UX and works, surely it cannot be so complex to ask for?

So in short:

1) How do I make the share dialog popup instead of redirect?

2) If there is no way to stop it redirecting, how do I get it to redirect back once a share is submitted?

3) Is there a problem with the way I have done this?

4) What recommendations would you make if this were your project?

5) Is there simpler documentation or a tutorial series that you may know of for the facebook sharing SDK? Because the docs on the developer site are pretty unclear and hardcore in places, I find.

Upvotes: 1

Views: 1716

Answers (1)

C3roe
C3roe

Reputation: 96455

My issue is that the "display=popup" parameter in the links query string does not do as it says, instead it redirects to a sharing page when I expect it to popup.

You misunderstood what this parameter does.

Of course browsers don’t open a normal link as a popup, just because the URL in the href attribute might or might not contain certain parameters.

The purpose of this parameter is to tell the dialog what setting it will be shown in – and if that’s popup, then the dialog elements are rendered smaller than they would be in the full page version.

1) How do I make the share dialog popup instead of redirect?

By either opening the target URL in a popup yourself (window.open), or by using the JS SDK instead, FB.ui can be used to call the dialogs and will open a popup to do so.

2) If there is no way to stop it redirecting, how do I get it to redirect back once a share is submitted?

For the URL version it is mandatory to specify the redirect_uri parameter, to tell the dialog where to redirect back to after sharing.

Upvotes: 1

Related Questions