How to enable single window mode in Safari

After browsing for a few hours in Safari it's possible to end up with a dozen windows or so because of links that open a new window (links with target="_blank"). I've always wished there was a way to have these links open in a new tab instead of a new window (sometimes referred to as single window mode).

In the latest Safari 3.1 Apple finally added a (hidden) preference! To enable single window mode and have all links open in a new tab that would normally have opened in a new window, we only need to enable the TargetedClicksCreateTabs preference using the following command (paste it into Terminal):

defaults write com.apple.Safari TargetedClicksCreateTabs -bool true

You might need to restart Safari before the setting is taken into effect. To disable the setting again, run the same command with false instead of true.

Have fun!

Update: thanks TUAW!

Update 2: check out my comment near the bottom for a possible way to do this on Windows. Update 3: I don't think The preference is not recognized in Safari for Windows.

Update 4: this setting does not appear to work in the Safari 4 Developer Preview.

Update 5: and it appears to be working again in the Safari 4 Developer Preview released on August 22nd!

Update 6: someone has been kind enough to point out that Safari 5.1 now has a user-facing preference that does this.

Love This!!!

I've been looking for a solution other than saft for a long time. About a week ago I finally got fed up and started using Firefox as my default browser because of this...

Now I'm back on Safari ... thank you thank you thank you!

I'm in the process of putting together a video based mactip website .. mind if I use it and credit you?

Blue

If you credit me, I don't see

If you credit me, I don't see why not!

Thanks.

--
Dennis

YEAH! thx! :O)

YEAH! thx! :O)

Good tip! Just in case, what

Good tip! Just in case, what is the command if one wants to return to the default preference?

Good one, I added

Good one, I added instructions to roll back!

--
Dennis

is there a way to have the

is there a way to have the new tab open in the background, much like the right-click-open-in-new-tab behavior, and to keep the tab that were surfing on in front?

yes with command+click on the

yes with command+click on the link you want to open in background!

But is there a way to make it

But is there a way to make it so left click is the default *and* the new tabs are created in the background?

Nope, apparently this hidden

Nope, apparently this hidden setting does not adhere to the Select tabs as they're created setting.

--
Dennis

But is there a way to make it

But is there a way to make it so left click is the default *and* the new tabs are created in the background ?

yes with command+click on the

yes with command+click on the link you want to open in background!

An itch finally scratched...

This issue has been bugging me for a LONG time, especially with Google's tabs between Gmail, calendar and reader always opening up in a new window. This is huge. Thanks!!

This issue has been bugging

This issue has been bugging me for a LONG time, especially with Google's tabs between Gmail, calendar and reader always opening up in a new window. This is huge. Thanks!!

It doesn't catch everything

As the preference name implies, this only applies to links with the target attribute set. This won't force links that open new windows via JavaScript to open in new tabs instead.

I've made a little plugin to force all all links that open windows to open tabs instead. You might find it useful: http://bitheap.org/singlewindow/

Where by plugin you mean hack..

..that will probably break safari at some point in the future?

If you're suggesting the

If you're suggesting the introduction of this new preference will eventually cause the plugin to render Safari unusable, I don't think that would ever be an issue. What would probably happen is that the preference would just be meaningless if you had the plugin installed (which is what happens now, in fact).

Someone beat me to it

I was going to suggest that this be added to Secrets, but I see that someone already beat me to it.

Secrets is a project by the creator of Quicksilver to make a simple interface to such hidden preferences. The key difference is that the list of hidden preference settings can be added to and modified by the community.

google SafariStand. One of

google SafariStand. One of its windows has this as a checkbox

Thanks this is awesome.

Thanks this is awesome.

How to enable single window mode in Safari

The SECRETS app from QUICKSILVER is a huge time saver and for first timers such as myself it shows me options that I want to change but probably would not be able to find.
Everyone should have it loaded up on their machine from the start!!
Definitely 10 out of 10.... absolute convenience.

Thank you!!!

I have complained bitterly about the lack of this feature for a long time. I mostly like everything else about Safari except that. You have made me a very happy girl.

Thank you!!!!

New Tab

I have been doing this with the old Safari as well by using the right click on the link (or control-click). It brings up a contextual menu, with the choice of opening in a new tab or new window.

Windows version? Pls find out

Windows version? Pls find out :)

Why nobody is helping the

Why nobody is helping the window users ;) How do you accomplish this Windows?

Please check whether this

Please check whether this works:

Quit Safari, make sure it is not running anymore. Open the XML file located at C:\Documents and Settings\insert your username\Application Data\Apple Computer\Safari\Preferences.plist in Notepad and just before the final </dict> and </plist>, add the following lines:

<key>TargetedClicksCreateTabs</key>
<true />

Of course, you can reverse by either removing the lines again or changing true into false.

Update: you might want to backup Preference.plist before you do this!

This might work, please let me know!

--
Dennis

i tried to follow your

i tried to follow your instructions for windows users, but there is a problem:
in the folder "preferences" there are two files: the first is "com.apple.Safari.plist" and the second is "PubSub.plist", even if I think that the second one is useless for our target. I opened and modified the first one because the name was the same of the command in the Apple users' instructions, but it doesn't work... besides when I open the xml file in the notepad there's a little thing like a square font before and after every single "key" in the file, so I copied and pasted at the end of the key that you gave.. but it doesn't work....so what could we do?
PS: I'm sorry for my english, but I'm italian and I'm not so good...:) I hope you will understand what I wrote.

Alright,

Alright, com.apple.Safari.plist is probably the right file. Please try using Wordpad instead of Notepad, since Wordpad supports Unix line-endings (that's what's causing the squares in Notepad).

You are using the latest Safari 3.1, right? It only works in that version (if it works at all on Windows).

--
Dennis

Yes I'm using Safari 3.1 ....

Yes I'm using Safari 3.1 .... and I modified the file with Wordpad(in which I didn't find Square fonts) ... but it doesn't work... maybe I should Reboot my pc?....
I hope someone will find a way to do this right because this function is quite useful when I surf the net....
ok I reboot and then I'll tell you sth....
Thanks

--

Mat

no... it doesn't work even if

no... it doesn't work even if I reboot.... so I'll wait...
Bye bye
--
Mat

Tried this on Windows (XP) Safari (3.1) too,

Tried adding it to com.apple.Safari.plist, didn't work for me either.

I am trying to find out

I am trying to find out whether this modification is possible in Windows and have found a number of potential files. I would appreciate if you could give me an idea what other lines of code should be in the file.

Some of the files of interest:

C:\Users\Username\AppData\Roaming\Apple Computer\Preferences\com.apple.Safari.plist

C:\Program Files\Common Files\Apple\Mobile Device Support\SyncServices\Clients\com.apple.Safari\Contents\Windows\com.apple.Safari

C:\Program Files\Common Files\Apple\Mobile Device Support\SyncServices\Clients\com.apple.Safari\Contents\Resources\com.apple.Safari.plist

Why nobody is helping the

Why nobody is helping the window users ;) How do you accomplish this Windows?

mpcoc

Ruined Popups For Me

I enabled this feature and noticed that it did disable the opening of popups, but it also doesn't open windows in new tabs for me. I tried to disable the option by setting the command value to "false" however that didn't work either. I've tried quitting safari after turning it on and then back off and still nothing. Now links with targets don't work for me at all. Don't run this unless you're willing to go through this glitch.

Safari 3.1 (5525.13)

Are you using any Safari

Are you using any Safari extensions/plugins? (Like SafariStand and whatnot.) Such weird behavior is usually caused by something foreign to Safari.

--
Dennis

You are the Sh*t!

After searching for a solution to tab browsing forever, I stumbled upon this page only to find the answer me, and I know many others have been looking for. Thank you. I believe you are something close to Jesus Christ.

I'm a moron....

I'm sorry, but I'm a recent PC convert. I don't have any clue what "paste it into terminal" means. How/where does one paste this snippet of code and then how would you trigger the command once it it wherever it needs to be?

Terminal allows you to run

Terminal allows you to run commands on a command line, similar to the Windows DOS prompt (or however it's called nowadays).

You open the Terminal application located in /Applications/Utilities (you can search for it using Spotlight also). Then paste the command and press enter to execute.

--
Dennis

Ok, and so every time I want

Ok, and so every time I want to activate this feature I have to go through these steps?

The command changes Safari's

The command changes Safari's preference file, so generally you only need to activate the feature only once.

--
Dennis

new target attribute?

So when do we get a target for a new tab instead of a new page? Tabs have been around for a while now.

target="_tab"

Safari in single mode

I just had Gmail open in a separate window, but it was not opening, so I looked under the Window drop down in Safari and I clicked on the option which said Merge All Windows. All my windows became tabs!! I did not know this was possible but it seems relevant to this discussion. Try it ... you'll like it...
Thanks...

This gets me where I want to be

But I have to keep doing it. Oh, maybe one days Windows users will be able to use TargetedClicksCreateTabs

Don't get it.. what was wrong

Don't get it.. what was wrong with the cmd-click that was required -without- the secret preference to open any link in a tab?

The point is that it will

The point is that it will open links, that would normally open in a new window, in a new tab instead. Without the preference, you'd have to hover over the link, look at the status bar (if you have it enabled) whether it will open in a new window, and if so hold down Cmd before clicking.

--
Dennis

Thanks!

Thanks so much for pointing this out Dennis!
I have been hoping this feature would be add for a few years.
Awesome!
Brad

Uhm, with Safari 5.1 (on Snow

Uhm, with Safari 5.1 (on Snow Leopard) all I had to do is to check the 1st option in the TAB preference tab (!), which says "Open the pages in tabs instead of windows: $CHOICE"

https://skitch.com/koolinus/fmjrs/pannelli

while your tip seems to NOT work anymore (again)

Uhm, I'm not claiming that

Uhm, I'm not claiming that this article still applies. I've added an update to the bottom of the post about the new option in Safari 5.1. In any case, thank for your contribution.

--
Dennis

And how to have Safari open

And how to have Safari open the links from one tab in the same tab ?