我有一個片段來創建一個「喜歡」按鈕,我們的新聞網站:如何改變Facebook的「喜歡」按鈕,「推薦」按鈕
<iframe id="likeButton" src="http://www.facebook.com/widgets/like.php?href="
scrolling="no" frameborder="0"
style="border:none; width:450px; height:80px"></iframe>
然而,爲了使其正常工作,因爲按鈕發佈一個錯誤說該按鈕是在一個無效的URL地址,我平添了幾分的jQuery來調整這樣的網址:
<script type="text/javascript">
$(document).ready(function(){
var imageFile = $('#likeButton').attr('src');
eval("imageFile = imageFile +"+"window.location.href;");
eval("$('#likeButton').attr('src', function(){return imageFile +"+"window.location.href;});");
});
</script>
那據我可以告訴工作。
我想改變按鈕從喜歡推薦和從Facebook的網站知道,我需要追加一個屬性的行動=推薦的URL。但作爲一個新手,我一直無法添加它,所以它的工作原理。我如何添加屬性到URL?
在添加action = recommend之前,您可能還需要去除原始動作= like參數。來自FB的默認Widget代碼在查詢字符串中包含action = like。 (意思是根據Josh的回答發佈這個) – nopuck4you 2010-10-06 18:46:33