简体   繁体   中英

facebook, how to redirect the user after login?

i am trying to redirect the user to a different page after a successful login.

i have this code:

<div id="fb-root"></div>
  <script src="http://connect.facebook.net/en_US/all.js"></script>
  <script>
     FB.init({ 
        appId:'11898121834', cookie:true, 
        status:true, xfbml:true 
     });
           FB.Event.subscribe('auth.login', function () {
      window.location = "facebook_login.php";
      //alert ("hello");
  });
  </script>
  <fb:login-button perms="email,user_checkins" >Login with Facebook</fb:login-button>

this wont work. the page refreshes but to the same page.

any ideas? Thanks

insert the new page you want to redirect to in the href attribute

FB.Event.subscribe('auth.login', function () {
      window.location.href = "http://example.com/newpage";

  });

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM