3

this is my code, as you can see it's very simple. there is an anchor that call a javascript method, and this opens a facebook popup shareing.

the problem is that the popup is not being closed after the user submit the comment.

<script language="javascript" type="text/javascript">
    function fbs_click() { 
    u = location.href; 
    t = document.title; 
    window.open('http://www.facebook.com/sharer.php?u=' + encodeURIComponent(u) + '&t=' + encodeURIComponent(t) + '&redirect_uri=' + encodeURIComponent('http://www2.highpoint.edu/close_popup.php'), 'sharer', 'toolbar=0,status=0,width=656,height=436'); return false; }
</script>
<a id="share-facebook" class="shareLink" href="http://www.facebook.com/share.php?u=<url>" onclick="return fbs_click()" target="_blank">Facebook</a>

can you help me please?

Ponja
  • 663
  • 1
  • 8
  • 15

4 Answers4

5

Was having the same problem, and came across the "feed dialog" - seems to have replaced the "sharer" functionality:

http://developers.facebook.com/docs/reference/dialogs/feed/

Aidan Feldman
  • 5,205
  • 36
  • 46
3

Please do not use the deprecated sharer.php. It might be totally removed from Facebook at any moment.

You should use the like or send plugin in it's place: http://developers.facebook.com/docs/reference/plugins/like/

DMCS
  • 31,720
  • 14
  • 71
  • 104
  • 1
    Good response, the like is the way to go here – thermz Feb 03 '12 at 18:19
  • 1
    I know what it means DMCS... I hate when that happens :-( – thermz Feb 04 '12 at 18:33
  • I don't think this really helps much. It is up to the coder to pick his tools. It is one thing to admonish against the use of an undocumented and possibly soon-to-be-deprecated tool, but that shouldn't let you sidestep providing an actual answer. – Michael Reed Feb 07 '12 at 18:13
  • 2
    Michael, Facebook will ignore any issues with the old sharer.php now that they've publicly posted that it is deprecated. Everyone should be told not to use something that might go "poof" at any time. A developer using stuff they knowingly is deprecated and still charges a client for their time, is dishonest in most people's book. It is not a good business model to do such things. – DMCS Feb 07 '12 at 19:30
  • 1
    the problem most devs/designers have with the new like/share buttons is the total inability to customize the icons. Facebook forces everyone to use their specific icons with zero method (as far as i know, please correct) to use your own images. – helgatheviking Jul 06 '12 at 18:29
  • Bingo! Because those devs/designers don't want to play by the Facebook TOS/TOU they agreed to and they abused it! Shame on those dishonest people for forcing Facebook to take this extreme action to make working with their API less prone to hacking. Welcome to living in a world where not everyone wants to play nice. Don't blame Facebook, blame those devs/designers who were being bad people! – DMCS Jul 09 '12 at 23:26
  • It's 2015 and sharer.php is still here. They'd rather you use the like button, because then you can't change the way it looks, and they get to track every user on your site (with a link to sharer.php, users only send data to FB when they actually like something). – Manu May 09 '15 at 07:33
  • Its mid 2022 - https://developers.facebook.com/docs/plugins/share-button - sharer.php is eventually used by invoking the JavaScript code. Why use the JavaScript code in the first place ? – anjanesh Jul 04 '22 at 16:32
  • Pretty crazy, eh? Not sure why things get marked as deprecated then hang out for another 10 years. Maybe too many people complained and they decided to maintain it afterall? – DMCS Sep 17 '22 at 15:08
2

If you use this undocumented URL for sharer.php, it will close the popup/window for you:

http://www.facebook.com/sharer.php?=100&p[url]=<url-to-share>

The popup will close itself. Make sure you URI encode the url to share. sharer.php will scrape the page for the og tags to get the title, image, etc.

Troy Morehouse
  • 5,320
  • 1
  • 27
  • 38
  • Hmm it appears this is not quite correct. `sharer.php` will only close the window if it is a true window (i.e. target="_blank" on the link) and not a popup (i.e. window.open(...) command) – Troy Morehouse May 04 '15 at 20:03
  • Even `onclick="window.open(url)"` is closing the popup window. – anjanesh Jul 04 '22 at 14:14
1

I've been working on this FB share button recently and I found the same issue. What I did was to switch to the Feed Dialog (as mentioned here), but you have to specify the app_id and rederect_uri. Jeremy provided a solution to close the window after you hit the share button (FB.ui popup window doesn't close).

Actually if you go to Digg's website and check out their facebook button, it's a Feed Dialog indeed and they just specified a redirect_uri with a simple JavaScript window.close.

But please be aware of the differences beetween FB share button and FB like button: FB like button will only be used once by the same account for the same link, while the FB share button allows anyone to share the same link for multiple times.

double-beep
  • 5,031
  • 17
  • 33
  • 41
Zhou Yuan
  • 161
  • 2