所以我一直無法讓我的Facebook像按鈕一樣工作。我試圖將它們放在很多頁面上,而無需每次都在代碼段的'href'字段中輸入url。我試過用js來動態改變href參數,但是當我點擊'like'按鈕時,它不會經過 - 又名不會發布到我的臉書。下面是代碼:Facebook的問題,如按鈕,XFBML,動態網址?
<script>
window.fbAsyncInit = function() {
// init the FB JS SDK
FB.init({
appId : '456678891040542', // App ID from the App Dashboard
channelUrl : '//WWW.UNICONUTRITION.COM/channel.html', // Channel File for x-domain communication
status : true, // check the login status upon init?
cookie : true, // set sessions cookies to allow your server to access the session?
xfbml : true // parse XFBML tags on this page?
});
// Additional initialization code such as adding Event Listeners goes here
};
// Load the SDK's source Asynchronously
(function(d){
var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
if (d.getElementById(id)) {return;}
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "//connect.facebook.net/en_US/all.js";
ref.parentNode.insertBefore(js, ref);
}(document));
</script>
<li class="sloo"><fb:like id="fb" href="www.asdf.com" layout="box_count"></fb:like>
</li>
<script type="text/javascript">
var sUrl = window.location;
document.getElementById('fb').setAttribute('href', sUrl);
</script>