I have a django view which is supposed to return HttpResponse depending on the status of the parent window which created the current window. If the parent window is still open, then I want to close the current window and redirect the parent window to some url, else if the parent window is closed then I want to redirect the new window to that url. Is there any way to determine this in my django view?
I tried this in Javascript
if (!window.opener.parent.closed){
    window.close();
    window.opener.parent.location.href="<url>";
}
else{
    window.location.href="<url>";
}
But the else block is not executed even if the parent window is closed, the if block works fine if the parent indow is open.
                        
If you are dealing with a window that popped up a new window, you should be checking for
window.opener.I would try the following code:
You can put the else in a timeout, as the parent window can be closed at any time without the child knowing.