Monday, September 14, 2009

Tip: Link to New Tab for Safari

It is very annoying when you open a link in Safari with "target='_blank'" attribute. The default action will open the link to a new window. Most browsers do have option settings to change this behaviour to a new Tab such as FireFox and IE. However, I could not find this kind setting in Safari's Preference.

One way to change the link to a new tab is to hold Command key and then click on the link. This works well, including the case that a link may not have "_blnak" attribute. Basically you can direct the link to a new tab with Command+click. This feature also works in FireFox (in Windows, you use Control key). However, I sometimes just forget to hold the Command key. Any way to change this settings?

Yes. I just found out that you can the Safari's default setting by using Terminal from Spotlight(Open Terminal from Command+Space). Then type the following command:

[Home] $ defaults write TargetedClicksCreateTabs -bool true

in this command, "defaults" is the command key word. You can find the description from man:

[Home $ man defaults

"" is a domain name in the format of Here the company is apple and application is Safari. Next one "TargetedClicksCreateTabs" is a key in the default settings for Safari. "-boo" is used to specify a type and "true" is the value to be set.

Before I tried to set this value to Safari's default setting, I worried about it may mass up my settings. So I tried to use read to check if this setting is already set or not, and what is the value if it is set:

[Home] $ defaults read TargetedClicksCreateTabs

The result is nothing. Then I think that if I set it, this will be a new setting in my Safari's defaults. It should be OK. I set it and checked it again by read option.

Since the word "TargetedClicksCreateTabs" is too long, I had several times typed it wrong. Then I tried to use grep to get the result (grep is a tool in UNIX to find a string):

[Home] $ defaults read | grep "Target"
TargetedClicksCreateTabs = 1;

The first part before | reads all the default settings for Safari. "|" pipes the result to the tool of "grep", which searches or filters for only lines with "Target" string.

No comments: