Related question: OAuth (Instagram) without refresh
The Situation
Instagram expects a full redirect for authentication, and then they'll redirect back. I want it to work with a popup.
Possible Solution
Open the page in a popup:
var authWindow = window.open(instagramUrl, 'authWindow');
Then I'll have instagram redirect to a page that closes itself:
<script>window.close()</script>
The Problem
I can't figure out how to find out when the window is closed. The following both don't work:
authWindow.onbeforeunload = function() {
window.opener.console.log('Closing popup!');
};
function logClose(cnsl) { cnsl.log('Closing popup!'); }
var callback = _.bind(logClose, window, console);
$(authWindow.document).click(callback);
Alternative suggestions are very wele!
Related question: OAuth (Instagram) without refresh
The Situation
Instagram expects a full redirect for authentication, and then they'll redirect back. I want it to work with a popup.
Possible Solution
Open the page in a popup:
var authWindow = window.open(instagramUrl, 'authWindow');
Then I'll have instagram redirect to a page that closes itself:
<script>window.close()</script>
The Problem
I can't figure out how to find out when the window is closed. The following both don't work:
authWindow.onbeforeunload = function() {
window.opener.console.log('Closing popup!');
};
function logClose(cnsl) { cnsl.log('Closing popup!'); }
var callback = _.bind(logClose, window, console);
$(authWindow.document).click(callback);
Alternative suggestions are very wele!
Share Improve this question edited May 23, 2017 at 11:59 CommunityBot 11 silver badge asked Jul 19, 2013 at 17:18 AJcodezAJcodez 34.4k20 gold badges87 silver badges118 bronze badges1 Answer
Reset to default 7Instead of using <script>window.close()</script>
directly, you could call a function in the parent window with window.opener
and then close the window:
Parent:
function onInstagramAuth()
{
// Handle however you would like here
console.log('authenticated');
}
Child:
try { window.opener.onInstagramAuth(); } catch (err) {}
window.close();
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745186647a4615670.html
评论列表(0条)