简体   繁体   中英

Create a facebook login button with javascript DOM

I'm trying to add a facebook login button using the dom (createElement, appendChild...) Following the facebook developper website, i wrote :

var loginFB = document.createElement('div');
    loginFB.id = "loginFacebook";
    loginFB.class="fb-login-button";
    loginFB.innerHTML = "Login with Facebook";

I also add in my javascript script the facebook function required.

And a div in my web page :

But this doesn't seem to work. I have a "Login with facebook" that appears but totally black.

Do you have an idea of how to achieve this ?

Thanks

I also add in my javascript script the facebook function required.

What exactly does that mean?

If you are adding XFBML tags after the SDK has finished loading, you have to call FB.XFBML.parse to explicitly have the document (or parts thereof) re-parsed for these tags.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM