Action 'onlogin' - Facebook button plugin

Asked

Viewed 250 times

0

I have an App on Facebook, and the home page has a button for if the user is not logged in to Facebook, do the same. This button is a plugin of Facebook itself. I have read all the documentation of this plugin, and this login button specifically has a configuration called 'onlogin', for if necessary, I run some JS function after login is successfully processed.

Right after the login process was done, I needed the full page to be made one Reload simple. It’s that way (simple of everything!):

<script>
     function reloadPage(){
        window.location.reload();
 }
 </script>

Here is the plugin ready button where I call the function on onlogin:

<div class="fb-login-button" data-max-rows="1" data-size="xlarge" data-show-faces="false" data-auto-logout-link="false" data-scope="email" onlogin="reload()"></div>

The case is that it just doesn’t work! How can I do it in some other way?

  • Your function name does not match what is on onlogin!

1 answer

1

In the onlogin button event, the name of the function to be called is reload.

The function you defined is called reloadPage.

Change of reload for reloadPage:

<div class="fb-login-button" data-max-rows="1" data-size="xlarge" data-show-faces="false" data-auto-logout-link="false" data-scope="email" onlogin="reloadPage"></div>

Sample code used in the test: https://gist.github.com/bzxbot/5064dae3bc64ff6b9349

For the page to be redirected, not iframe, use top.Location, rather than window.Location.

  • Sorry, man, I wrote the name of the wrong function call there. But still, it doesn’t work. =/

  • What is your page’s DOCTYPE? The onlogin property is only valid for HTML5.

  • DOCTYPE is already set to Html5.

  • I added an example page, test it with it and make sure the message is displayed on the console. Remember to exchange APPID for your app identifier.

  • It only gives a Reload in the app’s iframe... there is some way to reload the entire page?

  • I changed the sample code to do the redirect. Take a look. Basically, I use top.Location to do the redirect.

  • 1

    Thanks Bernardo! Saved my life. : D Even worth!

Show 2 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.