2010-12-31 10 views
0

こんにちは 私は外部のウェブサイトに置かれるウィジェットを開発しています。プラグイン全体はjavascriptで書かれていなければなりません。私はここにある検索haevが、Facebookのログインボタンウィジェットfacebookログインボタンがレンダリングされない

私のコードの上に表示されるようにすることができませんあなたはJavaScriptを使用して文書にXFBMLタグを入れている場合は、次の

var fbroot = document.createElement('div'); 
     fbroot.id = "fb-root"; 
     window.fbAsyncInit = function(){ 
      FB.init('xxxxxxxxxxxxxxxxxx', '/xd_receiver.htm');  
     }; 

    var contentRightDiv = document.createElement('div'); 
    contentRightDiv.id = "contentrightdiv"; 
    contentRightDiv.innerHTML = "<form><p><label>Sign in using <div id='socialmedialoginbtns'></div></label></p></form>"; 

var socialmedialoginbtns = document.getElementById('socialmedialoginbtns'); 
    socialmedialoginbtns.innerHTML = '<fb:login-button show-faces="false" width="200" max-rows="1"></fb:login-button>'; 
+1

はあなたのFacebook上のアプリを登録してのAppIDを持って、そしてあなたがFBのall.jsなどがなかったことがありますか? –

答えて

2

で、FBを使用します.XFBML.parse関数を使用して新しいタグをレンダリングします。

0

チェックこのコードスニペット....

`<!DOCTYPE html> 
<html xmlns="http://www.w3.org/1999/xhtml" 
xmlns:fb="http://www.facebook.com/2008/fbml"> 
    <body> 
    <div id="fb-root"></div><script type="text/javascript">` 
     window.fbAsyncInit = function() { 
     FB.init({appId: 'Your_App_ID', status: true, cookie: true, xfbml: true}); 
     }; 
     (function() { 
     var e = document.createElement('script'); 
     e.type = 'text/javascript'; 
     e.src = document.location.protocol + 
      '//connect.facebook.net/en_US/all.js'; 
     e.async = true; 
     document.getElementById('fb-root').appendChild(e); 
     }()); 
     window.fbAsyncInit = function() { 
     FB.init({appId: 'Your_App_ID', status: true, cookie: true, xfbml: true}); 

     /* All the events registered */ 
     FB.Event.subscribe('auth.login', function(response) { 
     // do something with response 
     getUserDetails(); 
     login(); 
     }); 
     FB.Event.subscribe('auth.logout', function(response) { 
     // do something with response 
     logout(); 
     }); 

     FB.getLoginStatus(function(response) { 
     if (response.session) { 
      // logged in and connected user, someone you know 
      login(); 
     } 
     }); 
    }; 

    </script> 
    <fb:login-button 
     autologoutlink="true" 
     perms="email,user_birthday,status_update,publish_stream"> 
    </fb:login-button> 
    </body> 
</html> 
関連する問題