1

In the Firefox webbrowser:
Is there a quick & simple way to close the current window and open a new window instead?

(Sidenote: For the purpose of this question, there is only 1 currently open window.)

What I am currently doing:

  1. initial state (focus is on this window)
  2. CTRL+N: open new window (focus is on new window now)
  3. ALT+Tab (in Windows): to switch back to the old window (focus is on old window now)
  4. CTRL+W: close old window (focus is on new window now)

Is there a more efficient way?
I am working on an old computer and the focus switch old window --> new window --> old window --> new window is lagging and consumes a lot of time. (And even if I had newer hardware available, I'd still want to operate as effectively as possible.)

The perfect solution for me would be to click on the "X" button to close the window and have Firefox closing the window and NOT quit/exit but opening a new window instead. This would require an imaginary about:config setting like browser.quitAppWithLastWindow=false by analogy to the existing about:config setting browser.tabs.closeWindowWithLastTab=false. But I assume there is no such setting?

I'd prefer a solution with built-in means (without adding an external program).

PS: In case someone asks, why I don't just close all tabs of the current window (CTRL+SHIFT+W) and be done with it?

  1. because in my experience opening a new/fresh window (instead of continuing to work in the same window) frees up more RAM
  2. because I want to have the benefits of a new window, e.g. CTRL+SHIFT+T doesn't open a closed tab from the previous (closed) window, which I don't need anymore

2 Answers 2

1

You could do this e.g. with a simple AutoHotKey script:

~^w::
Sleep, 1000
Run, firefox.exe
return
  • it intercepts Ctrl + W (^w)
  • passes it through (~)
  • waits for a second to ensure that the CLI command will go through (some browesers don't react to CLI if a window is already open or require different args)
  • opens firefox.exe, assuming that's in PATH env - if not, add its dir there or use full dir in the script.

Additionally, add IfWinActive directive checking for Firefox if you want the script to only apply to that program.


One more method is using Restart Browser extension with Method 4 of opening predefined URL.

2
  • +1 thank you. Although I'd prefer a solution without adding an external program.
    – summerrain
    Commented Jan 11 at 22:11
  • I heavily doubt that exists, but good luck. Mabe some random "restart" keybind.
    – Destroy666
    Commented Jan 11 at 22:37
1

There is a way to restart Firefox from within itself. And as long as you have not selected to open previous windows and tabs on startup, you get exactly what you ask, a new window. But whether it is a "quick and simple" way, well, it depends on how much super a user you are.

First enable the command line of the Browser Console (this links to the relevant section, but you might want to read the whole page). You do this just once.

Then every time you want to restart Firefox open the Browser Console (not the Web Console) copy the following snippet and execute it.

Services.obs.notifyObservers(null, "startupcache-invalidate");
Services.env.set("MOZ_DISABLE_SAFE_MODE_KEY", "1");
Services.startup.quit(
  Ci.nsIAppStartup.eAttemptQuit | Ci.nsIAppStartup.eRestart
);

That's it!

3
  • +1 thanks. This is a very creative answer. Yes, previous windows and tabs are restored on startup (by a session manager addon), so I doubt this would work. But what I don't understand: What is the advantage of your method over simply clicking on "X" to close and then clicking on the Firefox icon to (re)start ?
    – summerrain
    Commented Feb 23 at 20:13
  • 1
    It is very handy when there are more than a couple of windows open.
    – paa
    Commented Feb 26 at 11:30
  • thanks. How do you automate this? (instead of copy/pasting this codeblock each time)
    – summerrain
    Commented Feb 28 at 11:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .