Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Facebook permission popup blocked even when triggered by user event. Why?

Here is the page: http://textbookcentral.com.au/26/university-of-new-south-wales/buy/69897/acct1501/?query=

When the "Tell others I'm buying a textbook on my facebook wall." checkbox is checked and you click "Request this textbook", regardless if the form input data is valid or not, it'll attempt to make a wall post on your facebook wall, opening up a login dialog or permission dialog as necessary.

However, the dialog doesn't show if your browser blocked popups. I've tested this in Safari and Firefox.

The javascript is triggered only when you click the "Request this textbook" button, yet the popups are still blocked, why?

(View source, scroll down, and you'll see the following relevant code as well.)

<a href="#" class="submit button" onclick="make_facebook_request_post()">Request this textbook</a></p>
  </div>

  </form>

</div>
<script type="text/javascript">
function make_facebook_request_post() {

  if ($('#id_facebook').is(':checked')) {
    facebook.do_post(function(success) {}, 
      'I am using http://textbookcentral.com.au to buy a textbook for ACCT1501.', 'publish_stream')
  }

}
</script>

The facebook.do_post function will make the FB.api calls. See http://textbookcentral.com.au/site_media/static/central/js/facebook.js

like image 698
Eric Avatar asked Sep 05 '11 13:09

Eric


1 Answers

Yup, they specify this in their documentation.

http://developers.facebook.com/docs/reference/javascript/FB.login/

Calling FB.login results in the JS SDK attempting to open a popup window. As such, this method should only be called after a user click event, otherwise the popup window will be blocked by most browsers.

like image 179
Trevor Avatar answered Oct 25 '22 17:10

Trevor