1

I'm working on a firefox add-on and try to close a window with javascript. I'm using Firefox 24. When I try this:

window.close()

The window close but Firefox always ask me to confirm the closure. I don't want to see this confirmation box.

I tried to set dom.allow_scripts_to_close_windows in about:config, that will allow you to use window.close() function to close the window but it doesn't work.

I tried to disable the option browser.warnOnQuit in about:config but it doesn't work.

Has anyone a solution?

Thanks in advance

Passerby
  • 9,715
  • 2
  • 33
  • 50
  • Possible duplicate: http://stackoverflow.com/questions/2076299/how-to-close-current-tab-in-a-browser-window – CodeTherapist Jan 10 '14 at 08:17
  • You tag this as `firex-addon-sdk`, are you trying to close a content window via an add-on? Could you be more specific? Thanks! – ZER0 Jan 15 '14 at 08:55

1 Answers1

1

Normaly you can't close a window that was not opened by the open function in js. There is a little hack for that and I do not recommand this, because the user is maybe dissatisfied with this behavior.. But, try this:

window.open('', '_self', '').close();
CodeTherapist
  • 2,776
  • 14
  • 24
  • Thank you C Sharper for your answer. I already tried this but it doesn't work. The confirmation box still appears. Here is more details: I realized a firefox add-on which open some url (for each url -> open a window in fullscreen). This add-on use javascript to open each new window in fullscreen. I created a button to close direct all and if I click on it, I have the confirmation box for each windows. The problem I constated is if I try to close a window with javascript, this confirmation box appears. If I try to close normally, the confirmation box appears too. Thanks for your help – user3180833 Jan 10 '14 at 09:19