Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using the latest versions of Firefox and I'd like to disable the .focus() function's use for websites, is there any way to do this?

share|improve this question
Since I cannot comment here yet, I add an answer Can't you change to window.focus=function() { // whatever you want here return false; // no more focus } – mplungjan Feb 2 '11 at 6:59

There is a Greasemonkey script designed to allow you to disable this for Google.

The source code to that is here:

// ==UserScript==
// @name         Google Disable Auto Focus
// @namespace    googleDisableAutoFocus
// @include      /^http:\/\/(www\.)?google\.c(a|om)\/?$/i
// @include
// @match
// @match
// @run-at       document-start
// @datecreated  2010-02-21
// @lastupdated  2010-02-21
// @version      0.1
// @author       Erik Vergobbi Vold
// @license      GPL version 3 or any later version;
// @description  This userscript will disable Google's auto focus
// ==/UserScript==


Now, you could add sites that do this as additional @match lines in the ==UserScript== section, but there's no guarantee it would work. But if the focus event is set onload, then it would. It may affect other site behavior though.

share|improve this answer
I wrote that userscript. First of all, I want to disable .focus() from working altogether, albeit the issue usually happens onload but I often can't overwrite the onload event because it does more than just use focus(), and if the onload event listener is anonymously added then I cannot remove it. – erikvold Jun 27 '10 at 3:22
Hah! I didn't even notice that. Maybe onload get the identity of whatever's been focused, then blur() it. Or, I wonder if there's a way to completely alter the focus method, sort of like changing its .prototype -- though I don't know if there is such an equivalent. Lastly, maybe insert a shim object into the DOM as the last part of the onload event, focus it, then remove it from the DOM. – artlung Jun 27 '10 at 13:46
The main reason I want to disable focus() is so that I don't lose focus of what I was on. If I "insert a shim object into the DOM as the last part of the onload event, focus it, then remove it from the DOM" then I will still lose focus of what I was on I think. – erikvold Jun 27 '10 at 20:24
Erik, yeah, I see why the shim won't work in that case. :-( I'm out of ideas short of getting into the fundamental guts of Firefox. I'm wondering if the plugin api's would allow for what you are trying to do. – artlung Jun 29 '10 at 2:16

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.