Answer the question
In order to leave comments, you need to log in
How to implement authorization through social networks in a pop-up window?
Hello.
Wrote a class for authorization through social networks. The scheme of work is as follows: a
person presses the authorization button, in the same window redirects to the social page. network and then, after a successful login, redirecting back to the site.
But I want to do something like, for example, here - labirint.ru
When you press the login button through a social network, a new window opens, data is entered in it, and when there should be a redirect back to the site, this window is closed and the parent page is redirected, from which this window was opened.
I understand that this happens with the help of js, but I can not understand how it works. How a new window opens is clear. But how does it close at a certain moment and how does the parent page update?..
Answer the question
In order to leave comments, you need to log in
This all works through cross-origin messaging. After successful authorization, the script in the child window sends a message to the parent window to update the content.
The official way these days is postMessage .
There are a number of "crutches" for old browsers, which, for example, are implemented in one of the popular libraries - easyXDM .
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question