title: How to open and close popups with Javascript/FB.ui
body: <p>I wrote a simple function to launch a facebook share dialog popup. The problem is, when the user submits the share form the redirect config code in the html link sends the user back to my site <em>within</em> the popup, rather than closing the popup and displaying the response fb sends back. </p>
  
  <pre><code>function popwindow(url)
  {
  newwindow=window.open(url,'name','height=400,width=700');
  if (window.focus) {newwindow.focus()}
  }
  </code></pre>
  
  <p>with the html</p>
  
  <pre><code>&lt;a href="#" onclick="popwindow('http://www.facebook.com/dialog/feed?app_id=XXX&amp;link=somelink&amp;display=dialog&amp;redirect_uri=http://myurl.net/response/')"&gt;Share on Facebook&lt;/a&gt;
  </code></pre>
  
  <p><strong>Now I'm trying to figure out how to get FB's FB.ui js code to work</strong> (I'm a js beginner). I've looked through all the similar questions on stackoverflow to no avail. How do I write a link in my page's html to call a FB share dialog that pops up, submits when the user submits it, then closes the popup and sends the user to the proper confirm url with the proper response alerts?</p>
  
  <p>I have this default fb code in a facebook.js file</p>
  
  <pre><code>FB.ui(
  {
   method: 'feed',
   display: 'dialog'
  },
  function popwindow(url)
  {
  newwindow=window.open(url,'name','height=400,width=700');
  if (window.focus) {newwindow.focus()}
  }
  function(response) {
   if (response &amp;&amp; response.post_id) {
     alert('Post was published.');
   } else {
     alert('Post was not published.');
   }
  }
  );
  </code></pre>
  
  <p><strong>How do I write out an html link to call the popup and have FB.ui take care of it?</strong></p>