You and Your Middle Mouse Button

Mozilla has some behavior differences across platforms. One of the most noticeable differences for those of us who appreciate tabbed browsing is the behavior of the middle mouse button. By default, on Windows and OS X, depressing the middle mouse button over a tab will close that tab.

Among those I've asked, this behavior becomes very ingrained, and when switching back and forth between Windows and Linux machines, it is cause for great consternation. It doesn't work right. This is due to a user interface tradition. User interfaces work best if they're consistent. When was the last time you used a program that wouldn't copy with Ctrl-C or paste with Ctrl-V? (Substitute Command-C/Command-V on OS X.) When did you last double click on a word and not have that select it? So one would think it best if Mozilla worked the same everywhere, with middle click closing tabs.

But, on Linux, in X11 in general, middle click means paste. And Mozilla wasn't about to change that. So when you middle click, regardless of where on the screen, over a tab or no, the current clipboard is pasted to the location bar, and loaded. "That's not what I meant!" Annoying, but I learned to type Ctrl-W more often, which also closes a tab, and works consistently on all platforms.

But there's a better way. The setting middlemouse.contentLoadURL controls this behavior. Change this boolean value to false, and your middle mouse button will close tabs. Once more, your middle mouse button will continue to work for pasting into text fields.

Mozilla 1.4 or Greater

Starting with Mozilla 1.4, about:config allowed direct editing of preferences. This is useful for preferences which 'exist' but can't actually be changed in the normal Edit->Preferences dialog box. To change this setting, type about:config into your location bar. Now, click on the list*, type 'mi', and it should scroll down to the preference 'middlemouse.contentLoadURL'. Double-click on the preference and type 'false'. Hit 'Ok'. The setting should immediately take effect and automatically save.

(*) A digression. Formally speaking, Mozilla calls that list a tree. You can add and remove columns by clicking on the little box and arrow thingy as well as sort by any of the columns by clicking on the appropriate column heading. This complex widget courtesy of XUL.

Mozilla prior to 1.4

Since you can't change values in about:config in earlier versions of Mozilla, this is slightly harder. First, close all running Mozilla windows. Now find your user preference file users.js. The location of this file varies, but for me it can be found in ~/.mozilla/default/922do5t4.slt/. Typing find ~/. -name "prefs.js" on the command line will likely show you the location of this file. (This is not a good idea if you're root.) Open that file and insert a line containing user_pref("middlemouse.contentLoadURL", false);. Now, restart Mozilla and the change should take effect.

Middle Click to Paste

There is a related setting named middlemouse.paste which controls whether middle-clicking pastes in text fields, including the location bar. Again, this behavior is turned on by default in X11 versions of Mozilla and off in Windows versions of Mozilla. For the adventurous, this option can be turned on for that truly Linux-like experience on more stable legal commercial operating systems.


  1. "Mozilla Bug 110090 - provide edit field in about:config...",, Accessed 2004 Mar 04
  2. "Mozilla 1.4 Rough Changelog",, references Bug 110090, Accessed 2004 Mar 04
  3. "Mozilla FAQ for Linux Users", Copyright R.K.Aa., 2002 Feb 23,, Accessed 2004 Mar 04
  4. A few running copies of Mozilla to play with including "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2.1) Gecko/20030225" and "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4.1) Gecko/20031114"