检测何时加载Facebook Like Button
Detect when Facebook Like Button is loaded
你可能知道Facebook的"赞"按钮加载速度非常慢。
我正在尝试弄清楚如何检测按钮何时完成加载并已添加到网站。
原因是我显示了一个加载动画,然后隐藏它并显示按钮,但我想在完成加载时显示按钮。
这能做到吗?
提前感谢大家!
可以订阅 xfbml.render 事件以在渲染完成时收到通知,该事件每页解析仅触发一次(不仅适用于 xfbml,也适用于新的 html5 技巧)。如果 xfbml : true
加载 FB JS SDK,则会自动进行页面解析。
window.fbAsyncInit = function() {
FB.init({
...
xfbml : true
});
FB.Event.subscribe('xfbml.render', function(response) {
alert('OMG... All Facebook sociaal plugins on page rendereed.... finally!');
});
};
// And load the SDK Asynchronously here
我很确定facebook Like按钮被包裹在iFrame中。如果是,您可以找到引用该 iFrame 的内容并使用 ->
$('iframe[class/id/name=whatever]').load(function(){
//This element is loaded
});
编辑
根据您的特定需求,我们可以钩接到我评论中提到的任何属性,我只需选择要挂钩frameborder="0"
。
$('iframe[frameborder=0]').load(function(){
alert("loaded.");
});
如果您动态添加Facebook小部件并因此调用FB。手动 XFBML.parse,然后您可以简单地指定一个在渲染完成时调用的回调函数。
相关文章:
- javascript button target_blank?
- 获取打开jquery对话框的button的id
- javascript button ajax and php
- 模拟<按钮>在<asp:button>
- CKJustify和Color Button插件之间的不兼容
- 使用指令的angular js中的Like和different
- jQuery[button.class]未检测到用按钮追加行
- Webiopi multiple button css
- Like Unlike toggle button with jQuery's AJAX
- 检测何时加载Facebook Like Button
- AJAX and JS for LIKE Button
- Facebook Like Button不起作用
- Rails: Ajax for Like button when iterating through status up
- PHP / javascript like button
- Facebook Like button Jquery Javascript
- Ajax/jQuery "Like" button
- share-like button
- PHP MYSQL like button
- Facebook Like Button and Javascript
- 正在尝试在模型上创建Like Button