Jeff P.
asked on
How to redirect based on FB Login Status in all modern mobile and desktop browsers?
My company redirects a user based on if they are logged into Facebook or not. But we are having cross browser issues and I need another set of eyes.
Firefox blocks the connection to Facebook if tracking protection is on, not sure if I can get around that. I just need a popup to open even if login status fails. I tried a delayed meta refresh and that didn't even work.
Firefox blocks the connection to Facebook if tracking protection is on, not sure if I can get around that. I just need a popup to open even if login status fails. I tried a delayed meta refresh and that didn't even work.
<script>
window.fbAsyncInit = function() {
FB.init({appId: '' . $fb_app_id . '', status: true, cookie: true, xfbml: true});
FB.getLoginStatus(function(f) {
if (!f && f.status) return;
if (f.status == 'connected') {
var url = "http://google.com";
url = new URL(url);
window.open(url, "_self");
} else if (f.status == 'not_authorized') {
var url = "http://google.com";
url = new URL(url);
window.open(url, "_self");
} else {
var url = "http://gmail.com";
url = new URL(url);
window.open(url, "_self");
}
});
};
(function() {
var e = document.createElement('script'); e.async = true;
e.src = document.location.protocol +
'//connect.facebook.net/en_US/all.js';
document.getElementById('fb-root').appendChild(e);
}());
</script>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.