How to open facebook login dialog in same window instead of popup?

I have a website where users can log in to their Facebook account. I am using the javascript method FB.login to display the Facebook login dialog. By default, it causes a new popup to appear. Many users have blocked pop-ups in their browser. How do I make the facebook login dialog box appear in the same window where the user clicked the login button? I see that it works on this site

When the user clicks the "Login" button, he is redirected to facebook. After logging in to FB, it is redirected back to the original website. All in one browser tab.

+4
source share
4 answers

See: https://developers.facebook.com/docs/reference/dialogs/oauth/

Instead of using FB.login (), just add a link to your page as follows:

<a href="https://www.facebook.com/dialog/oauth/?client_id=YOUR_APP_ID&redirect_uri=YOUR_REDIRECT_URL&state=YOUR_STATE_VALUE&scope=COMMA_SEPARATED_LIST_OF_PERMISSION_NAMES">LOGIN!</a>

Facebook will then register the user and redirect him back to your URL with some goodies in the query bar:

 YOUR_REDIRECT_URI? error_reason=user_denied &error=access_denied &error_description=The+user+denied+your+request. &state=YOUR_STATE_VALUE 
+12
source

set the touch display do the trick

Example

 form method="get" action="https://graph.facebook.com/oauth/authorize" id="openid_form"> <input type="hidden" value="" name="client_id" id="client_id"/> <input type="hidden" value="touch" name="display" id="display"/> <input type="hidden" value="http://www.mobileborg.com/modules/openid/fb_callbackuri.php" name="redirect_uri" id="redirect_uri"/> <input type="hidden" value="email,read_stream,user_location,user_hometown,read_friendlists,user_photos,user_videos,publish_stream,offline_access" name="scope" id="scope"/> <div style="display:block"> <input type="hidden" name="oid_name" id="oid_name"/> <input type="hidden" size="40" class="openid-identifier" name="openid_identifier" id="openid_identifier"/> <input type="submit" style="display:none" value="Login" id="submit-button"/> </div> </form 
0
source

According to the Facebook documentation , you can use display=page , which opens in the same browser window.

0
source

My problem was that I had the External Links module turned on. He saw the external facebook URL and immediately added target = "_ blank", as a result of which all clicks will open in a new window.

0
source

Source: https://habr.com/ru/post/1402520/


All Articles