Warning: Trying to access array offset on value of type bool in /www/wwwroot/zklhy.com/wp-content/themes/twentyfifteen/functions.php on line 544

Warning: Trying to access array offset on value of type bool in /www/wwwroot/zklhy.com/wp-content/themes/twentyfifteen/functions.php on line 553

wordpress评论者网址在新窗口打开

最近网站来了不少人评论 不过都是广告 不过没事啦!来就来吧! 没有广告评论的网站不是好网站!

呵呵 不过这样也会出现一些问题 比如他填写了链接 然后重点是wordpress默认的是用到一个rel=”external nofollow” 标签 而这个标签和target=”_blank”是类似的 不过需要用javascrip配合使用才会有效果 所以我们需要做的就是添加这个javascrip 就好了

添加在头部header.php中即可:

<script type="text/javascript">
 function externallinks()
{
 if (!document.getElementsByTagName) return;
 var anchors = document.getElementsByTagName("a");
 for (var i=0; i<anchors.length; i++)
{
 var anchor = anchors[i];
 if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external nofollow")
{
anchor.target = "_blank";
}
}
}
window.onload = externallinks;
</script>

 

发表回复