Force 'new window' links to open in new tabs in Safari
在Safari新tab页中打开链接
翻译自macosxhints.com,原文链接:http://www.macosxhints.com/article.php?story=2008032109273043
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).
用Safari浏览网页一段时间后,你的桌面上可能已经布满了成打的窗口。那是因为有些网页默认是从新窗口打开(带有target="_blank"的链接)。我常常想从新tab中打开这些链接而不是新开一个窗口(所谓“单窗口模式”)。
In the latest Safari 3.1, Apple finally added a (hidden) preference to do just this! To enable single window mode, which forces all links that would normally open a new window appear in a new tab instead, we only need to enable the TargetedClicksCreateTabs preference using the following command (paste it into Terminal):
在最新的Sarifa 3.1版中,Apple添加了一个(隐藏的)设置来实现这一点!要实现单窗口模式来使本来会在新窗口中打开的链接出现在新的tab中,我们只要激活TargetedClicksCreateTabs属性就行了(粘贴到Terminal中执行):
defaults write com.apple.Safari TargetedClicksCreateTabs -bool true
[robg adds: This worked for me, but note that it will create those new tabs in the foreground, not the background. Command-clicking the link, however, will open the page in a new tab in the background (this has always been true, as I recall). The preference setting is mostly useful for sites you haven't visited before -- with it set, you'll not have window proliferation if you just click instead of command-clicking. To undo the setting, you can just delete the preference: defaults delete com.apple.Safari TargetedClicksCreateTabs. Make sure Safari's not running before you use either command.]
[robg注释:在 我的机子上这个方法行得通,但要注意如此那些新建的tabs会出现在最前面,而不是在后面。而按住Command键同时点链接的方法则使新tab在后台打 开(我试过都是如此)。在你浏览你从没去的网站时上述方法很有效——这样你就不会在点击链接后出现太多的窗口。要撤消这个设置,你只要用如下命令删除就行 了:defaults delete com.apple.Safari TargetedClicksCreateTabs。另外请注意运行这两个命令前一定要关闭Safari。]