1

According to Mozilla, window.close() won't work in FF if window is not opened with window.open();

We have implemented ExtJS in a project and a new window/tab is opened with anchor tag and target='_blank'. In new window, there is close button with js code: 'window.close();'.

As per mozilla standard, this code should not work at all but strangely it works in some cases and doesn't work in some cases.

Can anyone provide some hint/suggestion or workaround please?

Kulin Choksi
  • 761
  • 1
  • 11
  • 30
  • You want a workaround for something that does work sometimes, but shouldn't work at all? Just remove the code and the link. Problem solved. – GolezTrol Oct 26 '12 at 10:40
  • 1
    I think you misread something. `window.close()` will only work on windows opened with `window.open()`. You're trying to close the window, which called `window.open()`. Which in turn, wasn't opened this way, and thus cannot be closed. – Yoshi Oct 26 '12 at 10:41
  • @GolezTrol: Can you suggest any workaround for this issue?Surprisingly, it's working sometimes so it has became more crucial to deny for the solution. – Kulin Choksi Oct 26 '12 at 10:50
  • @Yoshi: ok, I got you, have removed the code from my question. – Kulin Choksi Oct 26 '12 at 10:51

1 Answers1

0

Try:

window.open('', '_self', '');
window.close();

Was having some issues on Chrome for iOS (in other browsers it works just fine). For that call close after a timeout > 300 as stated here

So code should look like:

window.open('', '_self', '');
setTimeout(window.close, 1000);
Community
  • 1
  • 1
Joao Leme
  • 9,598
  • 3
  • 33
  • 47