Window.closed Fail in Safari

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."
+4
source share
1 answer

A private property must be false while this window is still open.

Here is an example of how it works correctly. The warning will display true if it is closed, false if it is still open.

http://jsfiddle.net/QHXcG/2/

0
source

All Articles