Facebook共享对话框在新选项卡中打开,而不是在弹出窗口中打开

时间:2014-07-28 23:23:51

标签: html facebook dialog share

我正在尝试整合Facebook"分享"与SDK对话并在body标签的开头添加以下内容:

<script>
  window.fbAsyncInit = function() {
    FB.init({
      appId      : 'MY_APP_ID',
      xfbml      : true,
      version    : 'v2.0'
    });
  };

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

然后,作为测试链接,我有:

<a href="https://www.facebook.com/dialog/share?app_id=145634995501895&display=popup&href=https%3A%2F%2Fdevelopers.facebook.com%2Fdocs%2F&redirect_uri=https://developers.facebook.com/tools/explorer
">Test Facebook Link</a>

问题是,这会在新标签页中打开,当它真的应该在&#34;对话框中打开时#34;窗口。我做错了什么?

1 个答案:

答案 0 :(得分:1)

你想要:

<div class="fb-like" data-layout="box_count" data-action="like" data-show-faces="true" data-share="true" data-width="59" data-href="https://www.mysite.com/my-awesome-page"></div>

<div class="fb-share-button" data-href="https://developers.facebook.com/docs/plugins/" data-layout="button_count"></div>

请参阅:https://developers.facebook.com/docs/plugins/share-button/

Facebook JavaScript基本上将其换成了自己的HTML