Typecho 文章内链新窗口打开设置

我之前找了很多方法发现都是失效的,都是以前的版本的

方法一:添加parseContent() 函数 (推荐)

在主题function.php中添加

    function parseContent($obj){
    $options = Typecho_Widget::widget('Widget_Options');
    if(!empty($options->src_add) && !empty($options->cdn_add)){
        $obj->content = str_ireplace($options->src_add,$options->cdn_add,$obj->content);
    }
    $obj->content = preg_replace("/<a href=\"([^\"]*)\">/i", "<a href=\"\\1\" target=\"_blank\">", $obj->content);
    echo trim($obj->content);
}

需要rel=nofollow也可以自行添加,然后在修改主题内post.php将

<?php $this->content(); ?> 替换为 <?php parseContent($this); ?> 
<?php $this->content(); ?> 可以不删注释掉 //<?php $this->content(); ?> 温馨提示 这样的话<?php parseContent($this); ?> 就得添加到下一行

方法二:添加标签

在主题header.php文件中内加上

<base target="_blank"/><!--新窗口打开-->

这样有个坏处,就是新窗口泛滥