2011-08-03 21 views
1

我有一個iframe應用程序的Facebook選項卡,並在該選項卡中有一個像Facebook按鈕有Facebook功能的第二個功能。這是一個普通的Facebook像按鈕iframe。用戶點擊facebook之後的重定向按鈕

當用戶單擊按鈕時,是否有重定向用戶的可能性?我試了下面的代碼:

<div id="fb-root"></div> 
<script type="text/javascript"> 
    window.fbAsyncInit = function() { 
     FB.init({appId: '<my app id>', status: true, cookie: true, xfbml: true}); 
     FB.Canvas.setSize({ width: 520, height: 1500 }); 
     FB.Event.subscribe('edge.create', 
      function(response) { 
       alert('like!'); 
      } 
     ); 
    }; 

    //Load the SDK asynchronously 
    (function() { 
     var e = document.createElement('script'); e.async = true; 
      e.src = document.location.protocol + 
       '//connect.facebook.net/en_US/all.js'; 
      document.getElementById('fb-root').appendChild(e); 
    }()); 
</script> 

但是這不起作用。有沒有辦法或我做錯了什麼?

+0

像按鈕一樣正常運作嗎? – jBit

+0

可能的重複[如何重新定向一次facebook像按鈕被點擊?](http://stackoverflow.com/questions/6886102/how-can-i-redirect-once-facebook-like-button-is-clicked) – ifaour

回答

1

我只是測試下面的代碼和它的作品如預期

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml"> 
<head></head> 
<body> 
<div id="fb-root"></div> 

<fb:like href="http://yoururlto.like" send="false" width="450" show_faces="false" font=""></fb:like> 

<script type="text/javascript"> 
    window.fbAsyncInit = function() { 
     FB.init({appId: 'YOUR_APP_ID', status: true, cookie: true, xfbml: true}); 
     FB.Canvas.setSize({ width: 520, height: 1500 }); 
     FB.Event.subscribe('edge.create', 
      function(response) { 
       alert('like!'); 
       // put redirect code here eg 
       window.location = "http://www.mysite.com/redirected.html"; 
      } 
     ); 
    }; 

    //Load the SDK asynchronously 
    (function() { 
     var e = document.createElement('script'); e.async = true; 
      e.src = document.location.protocol + 
       '//connect.facebook.net/en_US/all.js'; 
      document.getElementById('fb-root').appendChild(e); 
    }()); 
</script> 
</body> 
</html> 

它是如何比較自己的網頁?

+0

像按鈕不是在fbml中實現,而是作爲iframe。 – stofl

+0

對不起。如果您必須使用iFrame,則不會觸發create.edge事件。 – jBit

+0

FB標籤只能在FBML-Tabs中工作,或者是fb javascript庫將它們替換爲html? – stofl

相關問題