8

Is there any Firefox extension or built in configuration that will allow disabling onload focusing in text fields?

I do not want to disable javascript. I'm just sick of certain sites auto-focusing in their search box when I have no intention of searching.

The annoyance is that if I'm interacting with a toolbar, or anything else, the focus instantly goes to the search box. Which then requires me to mouse back to the toolbar or whatever else I was doing.

Normally I wouldn't consider this to be a problem. But generally it goes: open new tab, click in toolbar, start typing. Half way through the page finishes loading, and half of what I typed is now in the search box and not the toolbar. Happens about 200 times a day...

  • Why do you care if they automatically give focus to a search box? You said it yourself, you're not searching simply browsing. Unless you plan on typing as soon as you hit the page I would think auto focus wouldn't be an issue. – Josh K Nov 4 '09 at 16:00
  • 3
    @Josh K, I use the up-down arrow keys for scrolling, and auto focusing of text input totally breaks that. – sayap Jul 7 '13 at 1:50
2

You can use the NoScript plugin which is kinda like killing ants with a sledgehammer, or you can try this greasemonkey script:

// ==UserScript==
// @name           Stop Google Stealing Focus
// @namespace      http://googlesystem.blogspot.com
// @include        http://www.google.*/
// @include        http://www.google.*/ig*
// ==/UserScript==

(function () {
    document.body.setAttribute('onload',''); 
})();

That works for me – who knows if it has any other side effects though?

| improve this answer | |
2

The add-on VimFX (which allows you to control your browser with the keyboard) has an option that prevents text fields from autofocusing, which works for me on all sites I tested so far.

Since VimFX makes some drastic changes to your interface, it might be a bit of an overkill (unless you are using it anyway) or interfere with other add-ons. You can probably disable all its other features, but I haven’t tested this. If anybody is interested in turning this into a stand-alone plugin, here is the relevant patch that introduced this feature.

| improve this answer | |
1

I do not know of anything specific, but as greasemonkey scripts run as soon as the DOM is populated but before the onload event handlers are called (as stated in http://greasemonkey.mozdev.org/authoring.html) you could write a script that disabled, or changed, the onload event for the sites you want the behaviour removed from.

You would have to do this on a per-site basis though, as some sites will do more than just refocus during the onload event and you probably want the other behaviour to run.

This also won't work for sites that do the refocus directly while the page is rendering (by calling the focus method directly in a <SCRIPT> block instead of in code called by the onload event.

It might be worth searching http://userscripts.org/ to see if there are any existing scripts there for the sites you want to change the behaviour of.

| improve this answer | |
  • 1
    Nice idea, but some libraries (jQuery) run scripts as soon as the DOM is ready. $(document).ready(function(){}); – Josh K Nov 4 '09 at 15:59
0

Vimium-ff has an option to prevent stealing of focus. (Options > Show Advanced Options > Don't let pages steal the focus on load).

If you wish to get rid of the main side-effect of using Vimium (the vim-like keybindings — though they're useful!), you can place unmapALL in the "Custom key mappings" section.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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