Search code examples
javascriptfacebookfacebook-javascript-sdkfeed

Facebook post to feed to open in a window


As of right now, this javascript:

<script>

  FB.init({appId: "123456789", status: true, cookie: true, xfbml:true });

  function postToFeed(description) {

    var obj = {
        method: 'feed',
        redirect_uri: 'http://thelivesite.com/',
        link: 'https://thelivesite.com/',
        picture: 'https://www.thelivesite.com/static/images/logo.png',
        name: 'TheLiveSite',
        caption: 'Here's a caption',
        description: description,
    };


    function callback(response) {
      document.getElementById('msg').innerHTML = "Post ID: " + response['post_id'];
    }

    FB.ui(obj, callback);
  }

</script>

 <div id='fb-root'></div>

<p style="position: absolute;">
     <a onclick='postToFeed("{{ item.title }}."); return false;'>Share</a>
</p>
<p id='msg'></p>

renders a box like this:

enter image description here

What do I have to do to make it a popout window dialog like this?:

enter image description here


Solution

  • Add this: display: "popup"

    var obj = {
        method: 'feed',
        redirect_uri: 'http://thelivesite.com/',
        link: 'https://thelivesite.com/',
        picture: 'https://www.thelivesite.com/static/images/logo.png',
        name: 'TheLiveSite',
        caption: "Here's a caption",
        description: description,
        display: "popup"
    };