I want to close current browser tab.
I have tried following
window.close();
and
var win = window.open('', '_self');
win.close();
But these are working fine in chrome but not working in firefox.
I have researched also on google but I didn't find any solution.
I know these question is posted before but I have seen theme and I didn't find solution for this.
The first step is to fool the browser into thinking that it was opened with a script...
window.open('','_parent','');
This opens a new page, (non-existent), into a target frame/window, (_parent which of course is the window in which the script is executed), and defines parameters such as window size etc, (in this case none are defined as none are needed). Now that the browser thinks a script opened a page we can quickly close it in the standard way...
window.close();
In Mozilla by default the "dom.allow_scripts_to_close_windows" value which controls the Java Script close window is set to "false". In order to fix this issue change this value to "true"
Location of the File:
C:\Program Files\Mozilla Firefox\greprefs\all.js
change "dom.allow_scripts_to_close_windows" from "false" to "true"
Example:
Default value
pref("dom.allow_scripts_to_close_windows", false);
Change it to:
pref("dom.allow_scripts_to_close_windows", true);
2.Close Mozilla browser
3.Try accessing HTML page which has window.close() code snippet
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With