开发者

Updating Facebook like URL in jQuery

I have the following script. As you can see it does update the fb href but for some strange reason the like fails to process. Have I messed something?

<html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script> 
</head>
<script>
$(document).ready(function() {
    $('#submit').click(function() {
        $('fb\\:like').attr('href', $("#URL"开发者_C百科).val());
    });
});
</script>
<body>

<div id="fb-root"></div>
<script src="http://connect.facebook.net/en_US/all.js#appId=174802005910704&amp;xfbml=1"></script>
<fb:like href="#" send="false" layout="box_count" width="80" show_faces="false" font=""></fb:like>
<input type="text" id="URL" />
<input type="button" id="submit" value="go">
</body>
</html>

Any help would be greatly appreciated.


No this will not do much because the <fb:like> tag has already been processed and rendered. all you are doing (if it actually works) is changing the attribute, which has no effect whatsoever

Try to explain what you are trying to accomplish and you will get a better answer


Add this to your html

<div class="share"></div>

On load and when a button is pressed or some state is changed call this function

function update_share_location() {

    // Empty previous share stuff
    $('.share').empty();

    // Your new share location
    var url_loc = 'http://yournewshare.com';

    share_options = '<iframe src="//www.facebook.com/plugins/like.php?href='+url_loc+'&amp;send=false&amp;layout=button_count&amp;width=250&amp;show_faces=false&amp;action=like&amp;colorscheme=light&amp;font&amp;height=26" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:200px; height:26px;" allowTransparency="true"></iframe>';

    // Update html
    $('.share').html(share_options);


}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜