Sunday, March 23, 2008

Mac: Making Safari open links in a tab

I've mentioned before that I really like Safari as my default browser, mainly because it's lightning fast, even more so with version 3.1. One of my pet peeves with it is the way it handles opening links that are targeted for a new window.

Links on a web page either go within the current browser window (or tab) or can be targeted to a window - the author of the page determines the target. Web sites will often target a new window because they don't want the user to leave their site. While this is all fine, I personally can't stand having a ton of browser windows open. The tabbed interface model for browsers is perfect for me - I like to open new browser windows as tabs and then be able to quickly switch between them.

There's a setting in Safari that allows you to open any link on a page in a new tab instead of a new browser window. Under Safari / Preferences / Tabs you can select the option that Command-Click opens any link in a new tab. I can also use my Logitech's scroll wheel button (Mouse Button 3) to perform that action.

The problem in Safari is that if the target for a link is a new window, Safari opened it in a new browser window. Man this drove me nuts until tonight.

Jon Sabino dropped in a comment on my last post mentioning an article on The Unofficial Apple Weblog about how to fix this problem. It's as simple as opening a terminal window and pasting in the following line:

defaults write com.apple.Safari TargetedClicksCreateTabs -bool true

Shut down Safari and restart it and off you go! From now on clicks that would normally open a whole new browser window will instead be targeted in a new tab in your current Safari window. 

Thanks for the great tip Jon!

6 comments:

Sean said...

It's a good thing to know. Thanks for the tip!

Aaron M said...

Thanks for the tip, I've always wondered that too.

I've never actually gotten myself to switch from Firefox to Safari but the more people preach Safari, the more I find myself going to it every time my Firefox crashes or hangs up (which is often). The thing that bugs me the most: switching tabs.

Does anyone know how to switch to a different tab if it's not the next one?

I know that Cmd + { or } will take you to the next or previous tab, but lets say I'm on tab 4 and I want to switch to switch to tab 1. In firefox you just press Cmd + 1, but in Safari that just opens your first bookmark. I hate having to move my hand to the mouse just to switch tabs, or mash a key 9 times just to get back to a different tab. Anyone?

David Alison said...

@aaron: You can move between tabs (provided you are not in a text input box) using Command-Shift Right or Left. It does cycle around so the worst case is you would have to go through half of your tabs.

I don't know of any other way. A quick Google search yielded nothing. Anybody else?

Eldfisco said...

Hi all! Wonderful blog David, and happy to read your Mac experience :)

Unfortunately no new tab tips, but thanks to a Google search I discovered an interesting file:

file:///Applications/Safari.app/Contents/Resources/Shortcuts.html

Hope you'll have fun with it :)

William said...

It has been interesting following you blog. From a new to Mac user to offering terminal command line tips. Time: less than two months!

g7whatever said...

I was just listening to macbreak weekly a podcast about all things mac and one safari tip that they pointed out is a site that points you to plugins similar to firefox called pimpmysafari.