windows 7 - How can I stop firefox (and possibly other browsers?) from stealing tab focus

26
2013-07
  • agent154

    I've got a website that I use for school, and it has a javascript function on it that pops up a window on the site after a certain period of inactivity to warn you that you'll be logged out. When this triggers and the tab is open in the background, it automatically switches to that tab even when I'm actively doing something on another tab.

    Can I set it so that it just does its thing without having to forcefully yank me back to that window?

    Using Firefox 16 on Windows 7. It also does it on my Windows 8 laptop.

  • Answers
    Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

    Related Question

    Can I keep Google from stealing my cursor in Firefox?
  • Matt Leidholm

    I have iGoogle as my home page. Every time that I start up Firefox with the intent to go to a specific page, I end up typing half the URL in the Google search box when iGoogle steals focus away from the URL bar. Is there any way to hack Firefox (or iGoogle) to keep the page from stealing my cursor on load? Thanks!


  • Related Answers
  • RoyalKnight

    Similar to Bevan's answer, but a little different. Two options you have.

    In your Firefox options, Main tab, General section, set Firefox to start up with a blank page. Set your homepage, however to iGoogle. Whenever you open up Firefox, you'll be greeted by a blank page that doesn't steal your focus. If you want iGoogle, just click Home or hit Alt+Home.

    Alternatively, which may or may not be better or for you, is to set your homepage to be

    about:blank|http://www.google.com/ig

    This will essentially load a blank screen in the first tab for you to go anywhere you want while iGoogle loads in the background. Want to just go to iGoogle? CTRL+F4 to close the blank screen, or a CTRL+Tab to switch tabs. I take it there's a reason you have iGoogle as your home page, which is why I mentioned this alternative.

    Other than that, there's no Firefox option to prevent a page from taking focus; while there's a userscript called Focus Killer that says it'll prevent such behavior, my own tests indicate it only does this after the fact; i.e. iGoogle took focus away from the address bar, then a bit later Focus Killer took focus away from iGoogle. In the end, there was no focus on the address bar.

    Only other option would be to disable scripts from running, but I don't think you'd want that at all.

    An annoying problem, I feel your pain (they'd do this during Gmail sign on while I was typing my password, so that it'd mess up both fields and show a large portion of my password due to me not stopping in time). This is the best I can come up with.

  • 8088

    Don't need to change your homepage. Here's a trick:

    Find the Firefox prefs.js file according to your OS:

    For XP:

    C:\Documents and Settings\<user>\Application Data\Mozilla\Firefox\Profiles\<profile>\
    

    For Vista:

    C:\Users\<user>\AppData\Roaming\Mozilla\Firefox\Profiles\<profile>\ 
    

    Below the comment area, directly above the existing directive lines, add the following 3 lines (swap yahoo.com with your offending page):

    user_pref("capability.policy.policynames", "nofocus");
    user_pref("capability.policy.nofocus.sites", "http://www.yahoo.com");
    user_pref("capability.policy.nofocus.HTMLInputElement.focus", "noAccess");
    

    If Firefox was open when you did this, it will overwrite your changes, so save it when Firefox is closed. Then reopen - good to go.

  • random

    One thing you could do is hit Esc before the rest of the page loads.

    This will stop it loading the rest of the page and by that, any JavaScript that will come along and start the focus of the browser on an input.

    Then carry on with Ctrl + L or F6 for the location or Ctrl + K if you wanted to use the search plugin.

    It's a temporary fix and you'll still be able to keep your default homepage without having to set it to about:blank.

  • Bevan

    Here's a workaround:

    Set your Firefox homepage to "blank" - then you can type a URL to your hearts content.

    Add the Google page to your links bar, so it's available just a click away.

    (Or, maybe not; you could just rely on the search built into Firefox)