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

Firefox-logo.pngWhen Firefox 3 started its beta program, I decided to give it a shot. Since then, I never came back to Firefox 2. Firefox 3 was faster, stronger, better ;) than its predecessor. However, there was one point where Firefox 3 has some problems : extensions. Many extensions where not working anymore. While this is now fixed with many extensions updated, Firefox 3 includes the new “places” functionnality that replaces bookmarks, history etc… And this new functionality irremediately broke my custom userchrome.js for opening bookmarks in tabs (without midlle clicking, that is). Since I only open bookmarks in tabs, with was a little troublesome for me, but, being the only grip I had, I decided to live with it. Until today, where I finally figured out how to write a new “magic line” in my userchrome.js, thanks partly to tab mix, partly to google, and partly to my brain :).

So, here is the complete howto:

  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 browser.search.openintab 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. How to open urls in a new tab. This one as well bookmarks requires userchrome.js. This is a very small extension that allows javascripts snippets to be executed the same way you have userChrome.css styles added to a page. I used version 0.8, but I think 0.7 version works as well. So go on and download it, then create a userChrome.js file 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). From this point, you can fill it directly with the code provided here or use the sub-script/overlay loader as in my own userchrome (allows the loading of other scripts). If you want, you can download my own userChrome.js directly and put it in the chrome folder. Now you can paste this code inside a .uc.js file in the same folder or inside userChrome.js:eval("BrowserLoadURL = " + BrowserLoadURL.toString().replace("e;", "$& if ((gBrowser.currentURI.spec != 'about:blank' || gBrowser.webProgress.isLoadingDocument)) { var tab = gBrowser.addTab(); gBrowser.selectedTab = tab; }"));
    This will open a new tab for url typed in url bar. You will have to restart your broswer to have the new behaviour.
  3. How to open bookmarks in new tab. This was the most difficult task since very few information is available on the internet. The key was using PlacesUIUtils for accessing functionnality. The code is:eval("PlacesUIUtils.openNodeIn = " + PlacesUIUtils.openNodeIn.toString().replace("openUILinkIn(aNode.uri, aWhere);","if ((gBrowser.currentURI.spec != 'about:blank' || gBrowser.webProgress.isLoadingDocument)) {openUILinkIn(aNode.uri, 'tab');}else{openUILinkIn(aNode.uri, aWhere);}"));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. As a bonus, you can download ChromaTabs for Firefox 3 if you like colored tabs. If you have any question or remark, please leave a comment. Have fun with firefox 3 !

Update: 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 = www.google.org in a new tab.
  • Bookmarks : Ctrl+Click on a bookmark opens it in a new tab.

29 commentaires

  1. big dj juin 1, 2008 23:46

    [...] i.e. url, bookmarks and search in a new tab. You can customize the method if you only want bookmarkhttp://www.x2b4.com/2008/06/01/how-to-open-everything-url-search-bookmarks-in-a-new-tab-with-firefox…Notorious B.I.G. - Dj Enuff Freestyle LyricsDownload Notorious big - Dj Enuff Freestyle Lyrics. Dj [...]

  2. Christian juin 6, 2008 0:57

    Re: How to open urls in a new tab.

    Thanks for the great instructions! I had googled this topic fr a loooong time, until I came to your site.

    Now, I discovered by chance that ALT-return also opens the urls in a new tab. But I guess you wanted this to always happen.

    tks again
    Christian

  3. x2b4 juin 6, 2008 18:04

    Hi Christian,

    Thanks you for your comment ! I searched google for quite a bit also :)
    I did not know the alt thing, this is great when I’m on another computer.
    I’ll include it in the tutorial.
    Thanks !

  4. jojo115 juin 9, 2008 17:41

    it doesn’t work in RC2 that the code open urls in a new tab , what problem?

    the code open bookmarks in new tab is ok, but it can’t work in sidebar

    and there is a code for open history in new tab?

  5. x2b4 juin 12, 2008 23:50

    Hi jojo115,
    I never encountered any problem opening history, however you are right, this code doesn’t work from sidebar. I’m not sure of what is causing it, I’ll try to have a look when I have some time.
    Also, you could try to upgrade in latest Firefox when it comes out and see if it works.
    Thanks for your support !

  6. Ron Kovic juin 14, 2008 10:59

    I followed these instructions for my Firefox 3.0 RC3 installation.

    I copied your userChrome.js to my profiles folder, then I copied your OpenInTabs.uc.js into the same folder.

    But it didn’t work. URLs that I entered into the address bar did not open in new tabs.

    I then copied your eval() function directly into the userChrome.js file, but that also didn’t work.

    In FF2, I used the TabMixPlus extension to configure all of my tab behaviours. But TMP hasn’t yet been released for FF3.

    So I really would like to get your nifty JavaScript solution to work.

    Do you have any ideas what the problem might be? Does your code work for FF3 RC3?

  7. x2b4 juin 14, 2008 11:50

    Hi Ron,

    Please make sure this is your Chrome folder inside your Profile, not directly your profile folder.
    On windows, this is usually:

    C:\Documents and Settings\\Application Data\Mozilla\Firefox\Profiles\ \chrome (by default it contains two files : userChrome-example.css and userContent-example.css)

    On linux, this is:

    ~/.mozilla/firefox/ /chrome

    If this was already the correct location, you can try to put this line in your userChrome.js:
    alert(”test”)
    and restart firefox. If this works & not the evals(), this need further investigation.

    Also a last note, did you verify that the userChrome.js extesion is correctly installed on your Firefox (i.e. shows up in your extension window).

  8. [...] 3. Du coup, tout le monde se met à rechercher Firefox 3 dans google (et notamment comment ouvrir les marque-pages dans des tabulations), ce qui entraîne par effet de bord des chutes sur mon site. C’est fou [...]

  9. sree juin 20, 2008 7:47

    they should have provided options for opening tabs for url and bkmarks in firefox 3.

    Script works fine. just a gripe, i’v got all these javascripts as bookmarks (like darken/change color of current page, etc).now these open in new tabs instead of opening in curent tab.surely there’d b a workaround for this. it’d b appreciated if u’d look into it (wd post updates if I come up with a solution)

  10. x2b4 juin 20, 2008 9:32

    Hi sree,

    I could not more agree with you, an option should be available. As for javascript as bookmarks, could you please provide me a sample code of such a bookmark so I can look into ?

    Thanks !

  11. adfs juin 20, 2008 14:19

    Does not seem to work for Mac OS X, FF 3. The alert(”test”) failed. Tried a new uc.js (downloaded the suggested), and also add to existing userChrome.js.

    Folder is here on my Mac: ~/Library/Application Support/Firefox/Profiles//chrome

  12. Marcos Hayun juin 22, 2008 15:05

    Hi x2b4,

    First of all, thanks for spending your time trying to help others with the same needs as you.
    I guess I need your particular help too. I am following your instructions as a cooker follows their recipe, which is even harder for me since I am not hacker material nor english is my native language.
    I seem to have managed the first two modifications very well. But I don’t understand what you mean with “The key was using PlacesUIUtils for accessing functionnality”. I will probably sound stupid and I probably am, but I tried to find this PlacesUIUtils as a complement, as a file, but failed in both attempts. I even tried to Google it but… Where, what or who is this PlacesUIUtils? What shall I do then?
    Thanks for your help!

    Marcos

  13. sree juin 22, 2008 21:02

    here is a sample javascript as bookmark
    *********
    javascript:(alert(”hello”))();
    *********
    the script goes in the location field of a bookmark. this works in address bar also. u could put any javascript in.
    javascript:(/*javascript*/)();

    identify and prevent bokkmarks/url’s starting with ‘javascript:’ from loading in new tabs.ma b

  14. zix juin 22, 2008 21:23

    It works with when I open a bookmark from the bookmark menu, but it doesn’t work when I open bookmark from the sidebar menu :(
    Did I do something wrong?
    Is it possible to make this work also for sidebar menu?

  15. x2b4 juin 23, 2008 0:13

    adfs: Are you sure the userchrome.js extension works on Mac ? I don’t have one myself, but I could ask a friend to test it.

    Marcos Hayun:

    Thank you for your comment. The PlaceUtils is not something you should do. In your case, the best thing is just to download OpenInTabs.uc.js (here: http://www.x2b4.com/wp-content/uploads/2008/06/OpenInTabs.uc.js) and put it in the chrome folder. Good luck !

    sree & zix : These are limitations of my current method. I will try to work around both problems next weekend. I think there is a solution, I just don’t know what it is yet. Stay tuned.

  16. Marcos Hayun juin 23, 2008 3:48

    Dear x2b4,

    I did it, I swear I did! Still doesn’t work for the favorites, neither on the toolbar or it’s menu. Works ok only for the google search bar.
    I even copied it and saved on both chrome folders, one in the root Firefox folder (C:\Arquivos de programas\Firefox\chrome) and the other one under “C:\Arquivos de programas\Firefox\defaults\profile\chrome”
    By the way, “Arquivos de programas” means Program files, in portuguese.
    Maybe I should delete the userChrome.js which is in the same place?
    And before you ask, yes, I restarted Firefox after doing that. No good, whatever.
    :-(

    Thank you once again,

    Marcos

  17. x2b4 juin 23, 2008 9:55

    Hi Marcos,

    Both chrome folder you tried are incorrect I think. The good chrome folder should be inside something like
    C:\Documents and Settings\[Windows login/user name]\Application Data\Mozilla\Firefox\Profiles\[profile folder]\chrome
    with of course Documents and Settings translated into Portuguese (if necessary). There are many chrome folders, but this one should work. Copy both userChrome.js and OpenInTabs.uc.js in this same place. Gook luck again ;)
    If you already tried this, forgive me :)

  18. Marcos Hayun juin 23, 2008 19:47

    Yessssssssss!!!!!!

    Now it works! Thank you very much!
    Since I was a Netcaptor orphan user, this was the only let-down that I was facing about Firefox.
    Hope I will be able to help you the same way in the future! Yet, that’s hard to believe…

    Once again, thank you!

    Marcos

  19. Mangrove juin 26, 2008 19:12

    Hi x2b4!

    Many thanks for posting this stuff.

    The good: I have installed the extension, some of the scripts from other sites are working and I’m very happy with them (”status bar in menu bar”, “DragNGo”).

    The bad: Unfortunately so far neither of your two scripts work for me. I’m using the first official release of Firefox 3.
    With the bookmarks script, it’s the same glitch that was pointed out before: new tab when called from menu, same tab when called from sidebar. For me however, it’s almost always the sidebar. I know this is doable since Tab Mix Plus used to do it. It would be great if you could figure out a way to do it, too.

    Stuff called from the address bar so far also hasn’t opened in new tabs with your method, but I’m now thinking this might be an incompatibility with one of my other extensions and I will do some exerpimenting.

    I’m definitely staying tuned to see if you can come up with any fix to the bookmarks issue.

  20. Mangrove juin 26, 2008 19:20

    For now, I’m back Tab Mix Plus. A working version for FF3 can be found here:

    http://tmp.garyr.net/forum/viewtopic.php?t=7031

  21. [...] with 3.0.  Today Google helped me find a (mildly involved, but not too terribly difficult) fix for that [...]

  22. Neolamprologus juillet 22, 2008 15:25

    Thanks to x2b4’s brain!

    This is a perfect solution for people that don’t want to install Tab Mix Plus or where Tab Mix Plus comes in conflict/has issues with other Firefox add-ons.

    I use the Tab Kit add-on for grouping and coloring related tabs. Some settings in Tab Kit and Tab Mix Plus comes in conflict , but with this “How to” I could remove Tab Mix Plus and have my tabs the way I like them.

    Thank you very much!

    -Neolamprologus

  23. x2b4 juillet 27, 2008 23:18

    Neolamprologus,

    Thanks for this comment :) ! This gives me the motivation to continue :p.

  24. Rainbow août 1, 2008 1:28

    After the crappy choice of removing some about:config entries from Firefox, I was disappointed. But this sounds a lot more promising than the heavy Tab Mix Plus thingy… I used to have Tabbrowser preferences installed in FF2, but it doesn’t have any official site anymore…

    Thanks for the post !

  25. Roger août 4, 2008 10:05

    Thank you so much. The instructions were so easy to follow. I really wanted this functionality. I didn’t want to have to press Alt+Enter every time I want the URL to open in a new window. I wish Tab Mix Plus worked with latest version of FF3.0.1 but this is a great solution!!! Many thanks again!!!!

  26. x2b4 août 4, 2008 22:54

    Ranbow, Roger, you’re welcome :)

  27. knackll août 5, 2008 21:27

    Thanks x2b4 it worked for me as well. Unfortunately the instructions did not come to me as clearly as others, but after a while I was able to get it to work. I do however have a comment about the tabs selected. Once I select a link from either the location bar or bookmarks my tab opens but my page does not switch to it immediately. I need to click on it. If you select tools/options/tabs/option to switch to it immediately is selected but it obviously does not work.
    Not the end of the world just an FYI.
    thanks again,
    knackll

  28. Rainbow août 8, 2008 8:25

    @knackll : it works fine for me and it focuses on the new tab when launching from URLbar or from bookmarks. I’m using a lot of extensions so it may be a inherited behavior…

    @x2b4 : the “dropping in the same folder…” trick does not work, I have to put every piece of code in my main userChrome.js to have it working, but since I don’t use a lot of .uc.js tricks it’s not a big deal !

  29. knackll août 8, 2008 15:57

    Rainbow, It does switch to the new tab immediately when opened fron the URLbar. But does not open from the bookmarks or personnel toolbar. I’ve tried some other options but just can’t see to get it to work. If I change the code around I can get it to switch to it immediately but it wont populate with the selection (meaning when bookmark is clicked the tab opens & switches to it but, the page becomes blank).
    I’ll play with it some more. Maybe, I’ll figure it out.
    Thanks,

Laisser un commentaire

Veuillez restez courtois et sur le sujet. Votre email ne sera jamais publié.