I've tried to do the facebook login using FB Javascript SDK.
After login doesn't close the login window only in opera browser. How can i fix this problem?
I've tried following source code: (on-line in this website - LINK)
<html>
<head></head>
<body>
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({
appId: '101103500012652', // App ID
channelUrl: '//www.milujse.cz/app/channel.html', // Channel File
status: true,
cookie: true,
xfbml: true
});
FB.Event.subscribe('auth.authResponseChange', function(response) {
if (response.status === 'connected') {
testAPI();
} else if (response.status === 'not_authorized') {
} else {
}
});
};
(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 = "//connect.facebook.net/en_US/all.js";
ref.parentNode.insertBefore(js, ref);
}(document));
function testAPI() {
FB.api('/me', function(response) {
alert('Good to see you, ' + response.name + '.');
});
}
function loginFB()
{
FB.login(function(response) {
if (response.authResponse) {
testAPI();
} else {
}
});
}
function logoutFB()
{
FB.logout(function(response) {
});
}
</script>
<input type="button" value="Login" onclick="loginFB();
return false;" />
<input type="button" value="Logout" onclick="logoutFB();
return false;" />
</body>
</html>
Have you considered checking the browser and if it's Opera using the other way to connect with facebook, I mean with oauth you can redirect the whole page to the facebook login page instead of using a popup and so you wont have the problem of not being able to close the popup. The link to the whole page si something like "https://graph.facebook.com/oauth/authorize?client_id=YOUR_CLIENT_ID&redirect_uri=http:YOUR_CALLBACK-URL&scope=WHAT_YOU_WANT"
There seems to be a bug in Opera in that Opera doesn't support the window.close() function on windows under some curcumstances.
This is referred to at javascript:window.close() and Opera as well as at https://bugzilla.mozilla.org/show_bug.cgi?id=190515 where this is listed as a bug.
It seems the window.closed() event is buggy too in Opera, as per http://dev.vaadin.com/ticket/5687
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With