Site icon David Yin's Blog

How to close Firefox windows without prompt

I have a batch file, to run the command and want to close it automatically.
Basically, I can use javascript to close it.
But it is always prompt that ask for Confirmation.
Actually I just want it run by schedule and close itself after finishing.
So, I use the Google BB (Big Buddha) to search it.
The final answer and only one answer is below.
The reason why the script is not working, is that Window is not opened by javascript. So it can not be closed by javascript automatically. It is simply concept. And the solution is also simply.


To close a window not opened with JavaScript you will have to change the Firefox options…
go to “about:config”
and set the value of “dom.allow_scripts_to_close_windows” to true…
Please be noted that you can not relay on it when you want to close the client’s Firefox window. I use it for my own computer. Because that you can not ask your user to set the value of it.
The code to close windows shown as below:

window.opener = null;
setTimeout('window.close();', 10000);
Exit mobile version