How can I close a window with Javascript on Mozilla Firefox 3?
function closeWindow() {
netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserWrite");
alert("This will close the window");
window.open('','_self');
window.close();
}
closeWindow();
window.close() doesn't work on Firefox, any work around?
Did your script open the window? Firefox 2 and later do not allow scripts to close windows that they did not open.
You could try this trick, but I have no idea whether it will work. I live on the side of the population that believes users should be in control of their browser windows, not applications (despite the fact you may have a good reason for this).
Close window with JavaScript background script? (Firefox Extension)
To close a window you created with browser.windows.create, you need to use browser.windows.remove.
So:
let windowId;
browser.windows.create({url: "http://google.be"}).then((data) => {
windowId = data.id;
});
// Sometime later, use windowId to close the window
setTimeout(function(){
browser.windows.remove(windowId);
}, 5000);
Related Topics
Why Do Empty JavaScript Arrays Evaluate to True in Conditional Structures
Jquery: Change Event to Input File on Ie
Why Is Usestate Not Triggering Re-Render
Why Escape_JavaScript Before Rendering a Partial
Create File with Google Drive API V3 (Javascript)
Execute an Exe File Using Node.Js
How to Sign into Google with Selenium Automation Because of "This Browser or App May Not Be Secure."
Passing Data to a Jquery UI Dialog
Why Does a Simple .*? Non-Greedy Regex Greedily Include Additional Characters Before a Match
How to Create a Date Object from String in JavaScript
Typeerror: Cannot Read Property 'Setstate' of Undefined
Do We Need Semicolon at the End
Attaching Click Event to a Jquery Object Not Yet Added to the Dom
Jquery Document.Ready VS Phonegap Deviceready