Facebook喜欢框加载事件jQuery [英] Facebook like box load event jquery
问题描述
$(document).ready(function(){
var highestCol = Math.max($('#main')。children()。height(),$('#main')。children()。height());
$('#main')。 children()。height(highestCol);
});
但是当我在某列中有Like框时,这不起作用。这似乎在Facebook之前调用的框称为。
如何解决这个问题?
基本上我需要在facebook加载之后调用这个过程与框和建议块(两者)一样。
我认为你可以把类似按钮
例如:
< ; div style =height:62px;>
< fb:like-box href =http://www.facebook.com/platformwidth =292show_faces =falsestream =falseheader =false>< / FB:像盒>
< / div>
然后您不会担心它的高度。
另一种可能的解决方案。
我想你使用异步加载facebook javascrpt sdk的方法。然后你可以在FB.init()之后执行你的代码。
< div id =fb-root>< / DIV>
< script>
window.fbAsyncInit = function(){
FB.init({appId:'your app id',status:true,cookie:true,xfbml:true});
if(jQuery.isFunction(window.fbexecute)){
window.fbexecute();
}
};
(function(){
var e = document.createElement('script'); e.async = true;
e.src = document.location.protocol +
' //connect.facebook.net/en_US/all.js';
document.getElementById('fb-root')。appendChild(e);
}());
< / script>
$ b $ var fbexecute = function(){
var highestCol = Math.max($('#main')。children()。height(),$('#main')。 。孩子()高度());
$('#main')。children()。height(highestCol);
}
I have code like this.
$(document).ready(function() {
var highestCol = Math.max($('#main').children().height(),$('#main').children().height());
$('#main').children().height(highestCol);
});
But this doesn't work when I have Like box in some column. It seems this called before Facebook like box called.
How to fix this problem?
Basically I need to call this process after facebook loads Like box and Recommendations blocks (both).
I think you can just put the like-button in a fix-height container.
For example:
<div style="height: 62px;">
<fb:like-box href="http://www.facebook.com/platform" width="292" show_faces="false" stream="false" header="false"></fb:like-box>
</div>
Then you won't worried about exactly how height it will be.
Another possible solution. I suppose that you using the method of load facebook javascrpt sdk asynchronously. Then you can execute your code after FB.init()
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({appId: 'your app id', status: true, cookie: true, xfbml: true});
if (jQuery.isFunction(window.fbexecute)) {
window.fbexecute();
}
};
(function() {
var e = document.createElement('script'); e.async = true;
e.src = document.location.protocol +
'//connect.facebook.net/en_US/all.js';
document.getElementById('fb-root').appendChild(e);
}());
</script>
var fbexecute = function() {
var highestCol = Math.max($('#main').children().height(),$('#main').children().height());
$('#main').children().height(highestCol);
}
这篇关于Facebook喜欢框加载事件jQuery的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!