1

我的likebox facebook 以正常方式正常工作。我想以这种方式为性能做:

jQuery(document).ready(function(){
jQuery("#facebook-likebox").mouseenter(function(){
jQuery("#facebook-likebox").append('<div style="background: white;" class="fb-like-box" data-href="https://www.facebook.com/xxx" data-width="292" data-height="410" data-show-faces="true" data-colorscheme="light" data-border-color="#197597" data-stream="false" data-header="false"></div>');

});
});

但它不起作用。页面加载[非异步]时如何关闭likebox fb?

4

1 回答 1

0

For this you'll have to load the Facebook JavaScript SDK. Once you have that initialized, you'll be able to call FB.XFBML.parse().

Taken from the documentation -

This function parses and renders XFBML markup in a document on the fly. This could be used if you send XFBML from your server via ajax and want to render it client side.

So what you would have to do, is on your mouseenter event call this function on the element containing the Facebook plugin -

FB.XFBML.parse(document.getElementById('facebook-likebox'));

Once the user has hovered over the area with the plugin, you should simply hide and display it (to preserve functionality). Right now your code would add it every time the mouse enters that area. There is no need to load it more than once.

于 2013-02-02T20:09:35.087 回答