Typecho文章/评论链接弹出新窗口

要不是吉在日记里写不习惯Markdown语法……我都快忘了这个了……78.gif Typecho是默认所有链接都在当前窗口打开,个人认为这样挺不适合阅读的……所以动手改改改!!以下是修改为“弹出新窗口”的方法~有了这个,再也不需要每个链接都加“target=_blank”啦!
(我已经写得超简单了,这个还看不懂的话我文章后面有附件,直接下载替换就好。)


  • 让评论者的主页在新窗口打开

首先打开\var\Widget\Abstract\Comments.php这个文件。找到第376行(或附近):

376
377
echo '<a href="' , $this->url , '"' , ($noFollow ? ' rel="external nofollow"' 
: NULL) , '>' , $this->author , '</a>';

替换为

376
377
echo '<a href="' , $this->url , '"' , ($noFollow ? ' rel="external nofollow"' 
: NULL) , ' target="_blank">' , $this->author , '</a>';

发现了吗?多加了个 target="_blank"就好啦!

懒癌发作的同学 【点我下载】 然后直接替换吧……好啦!去看看效果吧!


  • 让文章里的链接在新窗口打开

打开/var/CommonMark/HtmlRenderer.php文件,找到104

104
case CommonMark_Element_InlineElement::TYPE_LINK:
替换为
104
105
106
107
108
109
case CommonMark_Element_InlineElement::TYPE_LINK:
     $attrs['href'] = $this->escape($inline->getAttribute('destination'), true);
     $attrs['target'] = $this->escape(_blank, true);
     if ($title = $inline->getAttribute('title')) {
     $attrs['title'] = $this->escape($title, true);
  }

就成功啦!
懒癌的同学继续 【点我下载】 替换


大功告成~!114.gif