Ale*_*exK 12 facebook facebook-social-plugins
我必须实现一个Facebook-Likebutton,其中url取自ajax请求...这意味着我在页面加载后设置了"href" - 属性.不幸的是,此时网址已经设置,所以当喜欢它时,它会将实际的页面网址作为网址...有没有办法刷新像按钮?
小智 43
如果您正在使用jQuery,那么这个问题就是一个非常简单明了的解决方案:
$(document).ajaxComplete(function(){
try{
FB.XFBML.parse();
}catch(ex){}
});
Run Code Online (Sandbox Code Playgroud)
如果您使用 XFBML,我不知道如何更改 URL。但是,如果您使用 iframe,此代码片段应该可以工作:
超文本标记语言
<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.google.com&layout=standard&show_faces=true&width=450&action=like&font&colorscheme=light&height=80" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:80px;" allowTransparency="true" id="theiframe"></iframe>
<br />
<input id="url" />
<input id="btn" value="Change" type="button">
Run Code Online (Sandbox Code Playgroud)
jQuery
$('#btn').click(function(){
url = "";
url += 'http://www.facebook.com/plugins/like.php?';
url += 'href=' + $('#url').val() + '&layout=standard&';
url += 'show_faces=true&width=450&action=like&';
url += 'font&colorscheme=light&height=80';
$('#theiframe').attr({'src': url});
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
23809 次 |
| 最近记录: |