0

Possible Duplicate:
How to reload a page using Javascript?

I have the Facebook login working correctly except for the redirect after the user logs in.

Calling it here:

else {
echo '<h3>Please login with your Facebook account</h3>';
echo '<p>';
$f1->displayLoginButton();
echo '</p>';
}

$f1->displayLoginButton() defined here:

    function displayLoginButton() {
    echo '<fb:login-button show-faces="false" width="600" max-rows="1" scope="publish_stream, manage_pages, email"></fb:login-button>';
}

I'm pretty sure I just need to reload the page using something like:

window.location.reload()

But I'm not too familiar with JS. Can someone point me in the right direction?

Community
  • 1
  • 1
Paul Dessert
  • 6,363
  • 8
  • 47
  • 74

1 Answers1

2

Modify your <fb:login-button> to contain something like this: onlogin="afterFbLogin()", you should have something like this:

function displayLoginButton() {
    echo '<fb:login-button show-faces="false" width="600" max-rows="1" scope="publish_stream, manage_pages, email" onlogin="afterFbLogin()"></fb:login-button>';
}

What this does is tell FB's API to call afterFbLogin() JavaScript function when a user clicks the FB login button. Then simply put the code to reload the window (window.location.reload(true);) in that function that should be defined somewhere on your page.

Jan Hančič
  • 53,269
  • 16
  • 95
  • 99