Firefox: Open in Blank Tab

If you don’t use Firefox 3, go get it. Then finish this article. (Safari and Opera users are excused, but there’s no promise this will work for them.)

One of my (few) gripes with Firefox is that bookmarks on the toolbar have no “open in blank tab” option. They have an “open in sidebar” option, but those uses are rare and esoteric at best. Personally, I never use the sidebar.

“Open in blank tab” should basically do this: if there is a blank tab, use it; if not, create a new tab. Frankly, it could just open in a new tab regardless, but it seems like such an easy thing to add.

But? It can’t be done directly in Firefox. Hence, I present this small script:

  1. (function(){var u=’;
  2.   if(window.location‘about:blank’){
  3.     window.location=u;
  4.   }else{
  6.   }
  7. )();

That’s it. Try dragging this link to GMail{window.location=u;}else{,'');}})();) to your bookmark toolbar. Then click the link on your toolbar. Now, open a new tab, and click the link again.

This isn’t exactly what I asked for. It has no way of knowing if any blank tab exists, only if the current tab is blank. And, of course, it lacks the nice favicon support.

But it does the job. If you change the variable u to something other than ‘’, you can make the link open any other page.

I love anonymous functions.

Update: If you want a bookmark for something besides GMail, you can create your own;prompt('Copy the text below into a new bookmark.',"javascript:(function(){var u='"+u+"';if(window.location'about:blank'){window.location=u;}else{,'');}})();");})();). Or you can drag this link to your toolbar, to make new ones whenever you want: Open in Blank Tab{window.location=u;}else{,'');}})();");})();).

Update 2: Oops, fixed the “create your own” link. Tested it, then accidentally pasted in the results, instead of the actual script.