php 超链接新页面打开新页面,Typecho 超链接默认新窗口打开
本文最后更新于2021年03月17日,已超過11天沒有更新。如果文章內(nèi)容或圖片資源失效,請留言反饋,我會及時處理,謝謝!
ypecho默認的超鏈接是在當前窗口打開的,可能是由于個人習慣問題吧,每次打開一個網(wǎng)頁看完內(nèi)容后就隨手點擊關(guān)閉,一不小心就把整個網(wǎng)站都關(guān)閉了,非常的別扭。能不能讓typecho所有的超鏈接都是在新窗口打開呢?答案肯定是可以的。下面說下兩種實現(xiàn)方法:
方法一:修改系統(tǒng)模板文件
在 \var\CommonMark\HtmlRenderer.php的 104 行,是處理超級鏈接部分的代碼,我們只要添加一行$attrs['target'] = '_blank';即可,如下:case CommonMark_Element_InlineElement::TYPE_LINK:
$attrs['href'] = $this->escape($inline->getAttribute('destination'), true);
if ($title = $inline->getAttribute('title')) {
$attrs['title'] = $this->escape($title, true);
}
$attrs['target'] = '_blank'; #添加這一行代碼
return $this->inTags('a', $attrs, $this->renderInlines($inline->getAttribute('label')));
這種方法不推薦。
方法二:修改主題模板文件
直接在主題文件下的
標簽內(nèi)添加joe主題在/public/head.php文件最上面添加
推薦這種方法,簡單粗暴!
總結(jié)
以上是生活随笔為你收集整理的php 超链接新页面打开新页面,Typecho 超链接默认新窗口打开的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 给其他账户访问mysql的权限,将pos
- 下一篇: php getfooter,wordpr