即使由用户事件触发,Facebook 权限弹出窗口也会被阻止。为什么?
这是页面:http://textbookcentral.com .au/26/university-of-new-south-wales/buy/69897/acct1501/?query=
当“告诉其他人我正在购买我的 Facebook 墙上有一本教科书。”选中复选框并单击“请求此教科书”,无论表单输入数据是否有效,它都会尝试在您的 Facebook 墙上发布帖子,根据需要打开登录对话框或权限对话框。
但是,如果您的浏览器阻止了弹出窗口,则该对话框不会显示。我已经在 Safari 和 Firefox 中对此进行了测试。
仅当您单击“请求此教科书”按钮时才会触发 JavaScript,但弹出窗口仍然被阻止,为什么?
(查看源代码,向下滚动,您还会看到以下相关代码。)
<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>
facebook.do_post 函数将进行 FB.api 调用。 请参阅http://textbookcentral.com.au/site_media/static/central/js/facebook.js
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,他们在文档中指定了这一点。
http://developers.facebook.com/docs/reference/javascript/FB。登录/
Yup, they specify this in their documentation.
http://developers.facebook.com/docs/reference/javascript/FB.login/