Title: Facebook Login custom button fail
Tags: javascript;php;facebook
Question: I been looking to change the default button for login, I know there are several questions on this but I can't achieve this. I have tried several posts.
This is the code button which works, this is the original btn
<a href=&quot;javascript:void(0);&quot;&gt; <fb:login-button size=&quot;large&quot; scope='email,user_birthday'  onlogin=&quot;fb_login()&quot;&gt;<?php echo $this-&gt;get_variable('login');?&gt;</fb:login-button&gt;</a&gt;
This is the way I'm trying to set the button
<a href=&quot;javascript:void(0);&quot; onclick=&quot;fb_login();&quot;&gt;<img src=&quot;images/loginfacebook.png&quot; class=&quot;loginfbfb&quot; &gt;</a&gt;
and here is the JS code.
<script&gt;
window.fbAsyncInit = function() {
FB.init({
appId      : <?php echo $facebook-&gt;getAppID() ?&gt;,
status     : false,
cookie     : true,
xfbml      : true
});
};
(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 = &quot;//connect.facebook.net/en_US/all.js&quot;;
ref.parentNode.insertBefore(js, ref);
}(document));
function fb_login() {
FB.getLoginStatus(function(response) {
if (response.status === 'connected') {
// the user is logged in and has authenticated your
// app, and response.authResponse supplies
// the user's ID, a valid access token, a signed
// request, and the time the access token
// and signed request each expire
var uid = response.authResponse.userID;
var accessToken = response.authResponse.accessToken;
Set_Cookie( '<?php echo COOKIE_FBLOGINSUCCESS;?&gt;', 1, 0 , &quot;/&quot;+'<?php echo $srv_pats;?&gt;','<?php echo $srv_nms;?&gt;') ;

// location.href = &quot;<?php echo BASE?&gt;index.php?fb=fb&quot;;
window.location.reload();

} else if (response.status === 'not_authorized') {
// the user is logged in to Facebook,
// but has not authenticated your app
} else {
// the user isn't logged in to Facebook.
}
});
}
</script&gt;
Comment: @Reality yes i do, but its  with the script provided by Facebook yes....  Not javascript errors, the button just dont work, if im not logged in facebook, im not taken to a login view of facebook, to login in facebook.  With the default button i do.. im redirected to login with facebook.

Comment: do you have the div with id="fb_root" set up?

Comment: so what doesn't work? any javascript errors?



{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 0, 'CommentCount': 3, 'ContentLicense': 'CC BY-SA 4.0', 'CreationDate': '2013:00:10/21/13', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<javascript><php><facebook>', 'Title': 'Facebook Login custom button fail', 'ViewCount': 266, 'id': 19501675, 'user_AboutMe': None, 'user_AccountId': 3194433.0, 'user_DisplayName': 'Moncho Chavez', 'user_Reputation': 674.0, 'user_Views': 129.0, 'user_id': 2697960.0}}