Force Links to Open in New Tabs in Safari

One of the reasons I like Firefox is that it has a built-in setting (in the Tabs section of its preferences) to force links that want to open new windows to instead open in new tabs. I really hate "window proliferation" while browsing, and this setting makes it such that links which try to force a new window to open--such as the links on our own Mac OS X Hints Pick of the Week page--open in a new tab instead.

Safari doesn't have any such setting in its preferences--there is an option to make Command-click open links in new tabs, and that works on links that open new windows. However, if you'd rather not hold down the Command key, you can use a hidden preferences setting to force all such links to open in new tabs instead of new windows. To enable this feature, quit Safari and open Terminal (in Applications -> Utilities). Enter the following command, then press Return:

defaults write TargetedClicksCreateTabs -bool true

Launch Safari again, and you'll find that any links that would normally open new windows will open a new foreground tab instead. Because the tab comes to the foreground, I prefer to use the Command-click solution for my normal browsing, as that forces a new tab to open in the background.

However, I also have this hidden preference set, mainly for use when visiting sites I've never visited before. That way, I don't have to hold Command key down before clicking every link; if a link wants to open a new window, the worst I'll see is a new tab popping up in the foreground.

If you ever want to disable this hidden setting, quit Safari and open Terminal again, enter the following command, then press Return:

defaults delete TargetedClicksCreateTabs

Relaunch Safari, and links that request new windows will again appear in new windows. Thanks to Mac OS X Hints reader Dennis Stevense for finding this one.

This story, "Force Links to Open in New Tabs in Safari" was originally published by Macworld.

To comment on this article and other PCWorld content, visit our Facebook page or our Twitter feed.
Shop Tech Products at Amazon