1

How do you detect if window.close worked? I am using a function like:

function closePopupWindow() {
   self.close();
   var ww = window.open('', '_self'); 
   ww.close();
}

Which works well for the most part, but the close button doesn't always work due to browser settings, so I wanted to notify the user if the window doesn't close, that they will have to do it manually. I tried adding a timeout in the function, but that seems to get called regardless.

Any help would be appreciated. Thanks.

fanfavorite
  • 5,128
  • 1
  • 31
  • 58
  • 1
    [window.closed docs](https://developer.mozilla.org/en-US/docs/Web/API/window.closed) – ajp15243 May 28 '13 at 21:16
  • Is that compatible with all browsers? – fanfavorite May 28 '13 at 21:18
  • 2
    @fanfavorite The fact that MDN has this page indicates Firefox supports it. The MDN link says at the bottom: "`window.closed` is not part of any W3C specification or technical recommendation." However, they do then link to the [MSDN API doc](http://msdn.microsoft.com/en-us/library/ms533574(VS.85).aspx) underneath that, indicating that IE has it (the MSDN doc doesn't mention any IE versions unfortunately). I tried it in Chrome, and the property exists for me. I'm going to guess it's supported widely, but you should test the browsers you need/want to support. – ajp15243 May 28 '13 at 21:25

0 Answers0