I am using facebook javascript login sdk for a normal app. I have written a script for this. But i want to replace facebook login button with one of my custom image.
Asked
Active
Viewed 142 times
-1
-
Here is a fiddle for my script https://jsfiddle.net/2k052fwz/ – Upendra Sharma Feb 22 '16 at 12:04
-
your fiddle doesn't do squat – Jaromanda X Feb 22 '16 at 12:05
-
It is showimg fb login image on my local but not on fiddle. – Upendra Sharma Feb 22 '16 at 12:06
-
so, there must be a lot more wrong in your code than you think – Jaromanda X Feb 22 '16 at 12:07
-
Follow the simple step [Click Here](http://stackoverflow.com/questions/9810335/how-to-change-facebook-login-button-with-my-custom-image) – Ankit vadariya Feb 22 '16 at 12:07
-
check out my answer. for the future: please include all the neccessary details in your question (what have you tried so far? what is your code? where exactly did you get stuck? ...). – andyrandy Feb 22 '16 at 12:13
-
@luschn: i just want to replace exisiting fblogin image with any of custome image. I added html and javascript code but it is not showing image on fiddle but showing on local. – Upendra Sharma Feb 22 '16 at 12:19
-
we know that ;) - you should edit your question and add information instead of putting it in comments. always be as detailed as possible in your questions. anyway, check out my answer. that is how it works. you can style your button any way you want. – andyrandy Feb 22 '16 at 12:20
-
have a look on this url http://www.theumang.com/fblogin/ i want to remove this image – Upendra Sharma Feb 22 '16 at 12:40
-
again, check out my answer if you want to use your own image. everything´s there. – andyrandy Feb 22 '16 at 18:08
1 Answers
2
You can use your own login button by using FB.login of the JavaScript SDK.
HTML:
<button id="loginBtn">Facebook Login</button>
JavaScript:
document.getElementById('loginBtn').addEventListener('click', function() {
//do the login
FB.login(function(response) {
if (response.authResponse) {
//user just authorized your app
document.getElementById('loginBtn').style.display = 'none';
getUserData();
}
}, {scope: 'email,public_profile', return_scopes: true});
}, false);
More information: http://www.devils-heaven.com/facebook-javascript-sdk-login/
andyrandy
- 72,880
- 8
- 113
- 130