all articles

facebook share window duplicates when multiple calls

2015-07-30 @sunderls

facebook share window duplicate open js

description, bug always create new window for facebook share, while twitter share won't cause duplication.


$button.on('click', function(){'" + encodeURIComponent(''), 
        "width=200,height=200, resizable=yes,scrollbars=no");

every time $button is clicked, a new window prompts.

twitter share is just fine

twitter share url is


if we pass a name to,, name), no matter how many times you call, there would be only one window. But this doesn't work for facebook share.

Dig into the facebook share window, in the console, try logging


yes, facebook change the every time accessed, so the name passed in would not work.


keep a track of the window by yourself, never trust facebook

if (!window.fb || (window.fb && window.fb.closed)){
    window.fb ='" + encodeURIComponent(''), 
        "width=200,height=200, resizable=yes,scrollbars=no");
} else {