Tried to figure out, what's the case to use the window.opener.closed
flag? Looks like if the opener window is closed, the window.opener
variable is set to null
, so we can't access the .closed
property anyway.
Is there any situation when the opener window is actually closed, but the window.opener
is still available so we can check the .closed
property?
CodePudding user response:
So first of all, the behaviour of the closed
property is heavily browser dependent. In all modern browser (Firefox, Chrome, Edge) the logic is as you've described - upon the opener Window being closed window.opener
is nullified and the closed
property is no longer accessible. This is however not the case for IE, where you can access the property just fine.
Secondly, the behaviour you've described happens only if you close the window by the mouse event (e.g. hovering over the 'X' icon of the browser tab and clicking it). If you close the opener Window programmatically (so by using the close()
function), you'll see that the nullification process does not occur.