最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Facebook permission popup blocked even when triggered by user event. Why? - Stack Overflow

programmeradmin6浏览0评论

Here is the page: /?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  to buy a textbook for ACCT1501.', 'publish_stream')
  }

}
</script>

The facebook.do_post function will make the FB.api calls. See .js

Here is the page: http://textbookcentral..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..au to buy a textbook for ACCT1501.', 'publish_stream')
  }

}
</script>

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

Share Improve this question asked Sep 5, 2011 at 13:39 EricEric 1,1031 gold badge9 silver badges22 bronze badges 1
  • 4 Okay I got it... I cannot wrap the login call inside the init call. I must init the facebook sdk way before hand. Otherwise the login call isn't invoked by the userevent, but by an ining async response. – Eric Commented Sep 5, 2011 at 14:56
Add a ment  | 

1 Answer 1

Reset to default 5

Yup, they specify this in their documentation.

http://developers.facebook./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.

发布评论

评论列表(0)

  1. 暂无评论