How to open everything (url, search, bookmarks) in a new tab with Firefox 3.5 and 3.6


This is an updated Howto for Firefox 3.5 and Firefox 3.6 with the new extension UserChrome 1.1. You can still read the old howto for Firefox 3.0 and 3.1.

Here is how to open everything (yes, everything !) in a new tab.

  1. How to open search box in a new tab. This one is easy, just open about:config (type about:config in url bar) and filter with « search ». Look for and put its value to « true ». Voilà, new tabs for search box (a must if you ask me, plus combo if you have the right search engines – i.e. not only google).
  2. Install UserChrome 1.1 or more recent from the extension website.
  3. Create a userChrome.js in your chrome folder (inside your user profile folder, look at the Chrome folder article and Profile folder article on MozillaZine if you need help). Put this content inside:
    userChrome.import("*", "UChrm");
  4. How to open bookmarks in a new tab. Put this inside OpenInTab.uc.js in the same folder as userChrome.js.
    eval("PlacesUIUtils.openNodeIn = " + PlacesUIUtils.openNodeIn.toString().replace("openUILinkIn(aNode.uri, aWhere);","if ((gBrowser.currentURI.spec != 'about:blank' || gBrowser.webProgress.isLoadingDocument) && (aNode.uri.indexOf('javascript:') == -1)) {openUILinkIn(aNode.uri, 'tab');}else{openUILinkIn(aNode.uri, aWhere);}"));
    You will have to restart your broswer to have the new behaviour.
  5. How to open urls in new tab. Put this inside OpenInTab.uc.js in the same folder as userChrome.js.
    (function() {
    urlbar = document.getElementById("urlbar");
    eval("urlbar.handleCommand = " + urlbar.handleCommand.toString().replace("&& aTriggeringEvent.altKey","&& !aTriggeringEvent.altKey"));

    You will have to restart your broswer to have the new behaviour.

The whole OpenInTabs.uc.js is available if you want both functionality, just drop it into the same folder as userChrome.js.  If you have any question or remark, please leave a comment. Have fun with Firefox !

Note: If you want to have open in tab functionality for only some tabs, here are the shortcuts :

  • Url and search : Press Alt+Enter to open in a new tab. With url you can combine Alt with the classic Ctrl(end in .com), Shift(in .net) and Ctrl+Shift(in .org). That is, google +Ctrl+Shift+Alt = in a new tab.
  • Bookmarks : Ctrl+Click on a bookmark opens it in a new tab.

9 commentaires

  1. Hi.. was using this script of yours… had a couple of questions… is it possible to include a couple of ‘IF’ conditions in the ‘Open URL in New Tab’ script…
    – If the current tab is about:blank i.e. new tab
    – If the URL is a Javascript
    In these conditions, the URL should open in current tab and not a New Tab.

    Also, if you mouse-click on the urlbar dropdown list, it opens in the current tab instead of a new tab.

    Any suggestions? Thanks.

  2. I am trying out something like this but it doesn’t seem to work… any ideas?

    urlbar = document.getElementById(« urlbar »);
    if ((gBrowser.currentURI.spec != ‘about:blank’ || gBrowser.webProgress.isLoadingDocument) II (!gURLBar.value.match(/^javascript:/)))
    eval((« urlbar.handleCommand =  » + urlbar.handleCommand.toString().replace(« && aTriggeringEvent.altKey », »&& !aTriggeringEvent.altKey »));

  3. @Ronin

    This will not work. This is because we need to edit the « urlbar.handleCommand = » part for handling javacript&co. What you are doing is that _at browser launch_, if the current tab is blank, then change handleCommand function.

    What you could do is to look at the original handleCommand (you’ll have to unpack a jar maybe for that) and see what need to be replaced.

  4. can’t make sense of any of this. i want to open everything in new tab, but not like this.

  5. what do i have to change in your code to open a url in a new tab using ctrl key and enter?
    ps: i’m using firefox 4

  6. In recent Firefox versions they slightly changed urlbar.handleCommand, « &&  » prefix moved to the previous line. Omitting it works in Firefox 8.0.1 as well.

    (function() {
    urlbar = document.getElementById(« urlbar »);
    eval(« urlbar.handleCommand =  » + urlbar.handleCommand.toString().replace(« aTriggeringEvent.altKey », »!aTriggeringEvent.altKey »));

Laisser un commentaire

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *