I am having a weird issue with Javascript window.closed in Safari. When I open a new window and move in that window, the closed property will always remain false after closing.
Is this the default behavior in Safari? I have no problem in IE, Firefox and Chrome.
My code is:
var winRef = window.open(someURL); // ... Polling logic ... // Navigate in the opened window and close it. console.log(winRef.closed); // Will output false even though the window is closed.
The winRef variable winRef lose its link to the window while navigating the page.
The following steps will cause a problem in safari
- Use the sample code located here: http://jsfiddle.net/CMK7h/9/ and open in Safari
- Go to an open window on another page (do not use Google search, because this does not lead to page movement)
- Close open window
- The console should still display "Open."
source share