关注迷你日志公众号

Typecho也有评论链接跳转代码,首先打开var/Widget/Abstract/Comments.php文件,寻找

if ($this->url && $autoLink) {   
echo '<a href="' , $this->url , '"' , ($noFollow ? ' rel="external nofollow"' : NULL) , '>' , $this->author , '</a>';   
} else {   
echo $this->author;   
} 

修改为

if ($this->url && $autoLink) {   
if(strpos($this->url, $this->options->siteUrl)!==false) {   
echo '<a href="', $this->url, '">', $this->author, '</a>';   
} else {   
echo '<a href="', $this->options->siteUrl, 'go.html?url=', urlencode($this->url), '"', ' rel="nofollow"', '>', $this->author, '</a>';   
}   
} else {   
echo $this->author;   
} 

跳转页采用的是html静态页+javescript方式跳转,你也可以改用php方式,我的跳转go.html代码如下:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">   
<html xmlns="http://www.w3.org/1999/xhtml">   
<head profile="http://gmpg.org/xfn/11">   
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />   
<title>Microhu's Blog - 正常跳转</title>   
<style type="text/css">   
#show{width:500px;margin:100px auto 0;font-size:18px;color:blue;}   
#show span{color:red;font-weight:blod;}   
</style>   
</head>   
<body>   
<div id="show"></div>   
<script type="text/javascript">   
<!--   
function getUrl(){   
var theUrl=location.href.split('?url=');   
if(theUrl.length==1)   
return 'https://minirizhi.com';   
return decodeURIComponent(theUrl[1]);   
}   
var showme=document.getElementById('show');   
showme.innerHTML='正在为你跳转到:<span>'+getUrl()+'</span>';   
location=getUrl();   
//-->   
</script>   
</body>   
</html> 
转载请注明出处,谢谢!
本文地址:https://minirizhi.com/jianzhan/24.html
THE END

话题: 评论代码, 重定向

  • Typecho自定义评论样式
  • Typecho多级分类调用代码