How to Close a Window with JavaScript on Mozilla Firefox 3

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



Leave a reply



Submit