I am using an Instagram API and the only way to log out is through the link https://instagram.com/accounts/logout/ which will redirect the user to the Instagram page (if someone knows an alternative method please let me know). However, I want to redirect the user to my own page. (I had previously tried the methods to do so in this post. The img
/iframe
will append and redirect the user to my page, but the user was still signed in.)
This is the code that I am currently using:
$('.logout').on("click", function () {
window.open('https://instagram.com/accounts/logout/');
window.close();
window.location.replace("logout-page.html");
}
The Instagram page successfully opens in a new tab and signs the user out, while my page redirects to the logout page, but I want the Instagram logout page to close on its own after its opens. Other people were saying that window.close()
works only when it was opened via script using window.open()
, which I am doing and it still does not work. I have also tried window.open("", self).close()
and other variations of that and those did not work for me either.