title: Cancelling from Facebook Permissions dialog redirects and does not close
body: <p>I am trying to add Facebook login functionality to my web site using Javascript.
  I have called FB.init and FB.login and get the expected popup window that asks me to log in with my Facebook credentials.  The call to FB.login requests user_birthday and email permissions so I also get the expected dialog that asks me to allow those permissions.  If I accept, the login works and control returns to my parent page.</p>
  
  <p>If I do not accept the permissions (hit the Cancel button), what happens next seems to be inconsistent.  What I was hoping was that the popup window would go away and return control to the parent window which would then be able to handle the denied response.  Ultimately I want to give my users a message letting them know what happens when they cancel.  </p>
  
  <p>Instead, I sometimes see the popup window redirect to the main Facebook page that you see when you log directly into Facebook.  Sometimes the popup window becomes blank and just sits there (it is pointing to the ChannelUrl page that I specified in the FB.init call).  In both cases, control is not returned to the parent page until I manually close the popup window.</p>
  
  <p>Sample Code:</p>
  
  <pre><code>&lt;html&gt;
  &lt;body&gt;
  &lt;div id="fb-root"&gt;&lt;/div&gt;
  &lt;script language="Javascript"&gt;
  window.fbAsyncInit = function() {
      FB.init({
          AppId      : 'XXXXXXX',
          channelUrl: 'http://www.mydomain.com/channel.html', //custom channel
          status: true,
          cookie: true, 
          xfbml:  true,
          oauth: true
    });
  
  };
  
  // Load the SDK Asynchronously
  (function(d){
       var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
       if (d.getElementById(id)) {return;}
       js = d.createElement('script'); js.id = id; js.async = true;
       js.src = "//connect.facebook.net/en_US/all.js";
       ref.parentNode.insertBefore(js, ref);
  }(document))
  
  function fbLogin()
  {
      FB.login(function (response){
          if (response.authResponse) {
              Debug("Auth Logged in");
          }
          else
          {
              Debug("Auth failed");
          }
      }, {scope:'user_birthday,email'});
  }
  
  function Debug(psMessage)
  {  // something to provide feedback on what happened...
      var objDebug = document.getElementById("Debug");
      var objDate = new Date();
      var sTime = objDate.getHours() + ":" + objDate.getMinutes() + ":" + objDate.getSeconds();
      objDebug.innerHTML = sTime + " - " + psMessage + "&lt;br&gt;" + objDebug.innerHTML;
  }
  &lt;/script&gt;
  &lt;form&gt;
  &lt;input type="button" value="Log in" onClick="fbLogin();"&gt;
  &lt;br&gt;
  &lt;br&gt;
  &lt;br&gt;
  &lt;br&gt;
  &lt;div id="Debug"&gt;&lt;/div&gt;
  &lt;/form&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>I have tried a variety of things.  I have deleted and created a new application.  I created the channelUrl parameter (it only includes 
  <code>&lt;script src="//connect.facebook.net/en_US/all.js"&gt;&lt;/script&gt;</code>).</p>
  
  <p>Does anyone have any insight as to what I’m doing wrong (this seems to happen at least in IE8, Safari 5.0.5, and Firefox 11.0 all on Windows XP)?</p>
  
  <p>Thanks for any help!</p>