Question

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

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top