Click here to Skip to main content
15,889,820 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have following js function
JavaScript
function closeMe()
{
    window.open('','_parent','');
    window.close();
}


for closing window its working on IE,But it will not work on firefox
any function for close button working on firefox please suggest me.
Posted
Updated 28-Aug-20 18:31pm
v2

you can see this link
Click
Here, 3 solutions are given.
 
Share this answer
 
That might be what you are looking for:
C#
function closeWindow() {
    netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserWrite");
    alert("This will close the window");
    window.open('','_self');
    window.close();
}


Good luck
 
Share this answer
 
for mozila:
about:config
search dom.allow_scripts_to_close_windows
and change false to true
close the browser
then
window.close();
working perfectly


for dynamically firefox and chrome in click event

var browsernames = (function (test) {
switch (true) {
case test.indexOf("edge") > -1: return "edge";
case test.indexOf("edg") > -1: return "chromium based edge (dev or canary)";
case test.indexOf("opr") > -1 && !!window.opr: return "opera";
case test.indexOf("chrome") > -1 && !!window.chrome: return "chrome";
case test.indexOf("trident") > -1: return "ie";
case test.indexOf("firefox") > -1: return "firefox";
case test.indexOf("safari") > -1: return "safari";
default: return "other";
}
})(window.navigator.userAgent.toLowerCase());
// alert(browser);

if (browsernames == 'chrome')
{
var win = window.open("", "_self");
win.close();
}
if (browsernames == 'firefox')
{
// window.open('', '_parent', '');
window.close();
}
 
Share this answer
 
v4
win.open return a reference to the open window
try this code

C#
var myWin = window.open('','_parent','');
myWin.close();



it will work

mithun thakur
 
Share this answer
 
Comments
rajjosh 28-Sep-11 3:19am    
it not work in firefox

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900