Z-Blog 评论留言的引用按钮写法详解
作者:xlnxin发布时间:2021-04-15分类:Zblog教程浏览:396
导读:Z-Blog博客的评论留言引用按钮的写法在Z-Blog官方的Wiki里也有说明,制作Z-Blog主题对评论留言的引用按钮进行编写的时候去看过官方的讲解,感觉Z...
Z-Blog 博客的评论留言引用按钮的写法在 Z-Blog 官方的Wiki里也有说明,制作 Z-Blog 主题对评论留言的引用按钮进行编写的时候去看过官方的讲解,感觉 Z-Blog 官方Wiki给出的相关说明太过于简单,对新手的话可能会造理解上的一些错误,我之前就有这类似经历,导致我花了过多的时候在引用按钮的写法上面。
Z-Blog 引用所用的JS函数:
- 引用的函数: InsertQuote(参数1[评论者],参数2[评论内容])
- this.parentNode 表示该节点的上一节点
- getElementsByTagName(‘a’)[2].innerHTML 表示获取第二个元素的内容,即<#article/comment/name#>
- 同上,getElementsByTagName(‘li’)[2].innerHTML 为<#article/comment/content#>
注:其中getElementsByTagName(‘a’)[2]中的a和2是要按实际变化的;getElementsByTagName(‘li’)[2]也一样。
Z-Blog 默认主题的模板b_article_comment.html代码结构如下:
<ul class="msg"> <li class="msgname"><span class="comment-quote-icon"><a onclick="InsertQuote(this.parentNode.parentNode.parentNode.getElementsByTagName('a')[2].innerHTML,this.parentNode.parentNode.parentNode.getElementsByTagName('li')[2].innerHTML);return false;" href=""><img src="<#ZC_BLOG_HOST#>image/common/quote.gif" height="9" width="9" alt="quote" title="quote" /></a></span> <a name="cmt<#article/comment/id#>"><#article/comment/count#></a>.<a><#article/comment/name#></a></li> <li class="msgurl"><a href="<#article/comment/urlencoder#>" rel="nofollow" target="_blank"><#article/comment/url#></a></li> <li class="msgarticle"><#article/comment/content#></li> <li class="msgtime"><#article/comment/posttime#> <a href="#comment" onclick="RevertComment('<#article/comment/id#>')"><#ZC_MSG265#></a></li> </ul> |
其引用按钮写法如下:
<a onclick="InsertQuote(this.parentNode.parentNode.parentNode.getElementsByTagName('a')[2].innerHTML,this.parentNode.parentNode.parentNode.getElementsByTagName('li')[2].innerHTML);return false;" href=""><img src="<#ZC_BLOG_HOST#>image/common/quote.gif" height="9" width="9" alt="quote" title="quote" /></a></span> |
更改代码结构的写法示例:
- 如果b_article_comment.html代码结构如下:
<div class="msg"> <cite>评论者</cite> <blockquote>评论内容</blockquote> <p>网站</p> <p>时间</p> </div>
- 添加评论引用按钮后的代码如下:
<div class="msg"> <a onclick="InsertQuote(this.parentNode.getElementsByTagName('CITE')[0].innerHTML,this.parentNode.getElementsByTagName('BLOCKQUOTE')[0].innerHTML);return false;" href="#comment">引用</a> <cite>评论者</cite> <blockquote>评论内容</blockquote> <p>网站</p> <p>时间</p> </div>
看其引用按钮写法是
<a onclick="InsertQuote(this.parentNode.getElementsByTagName('CITE')[0].innerHTML,this.parentNode.getElementsByTagName('BLOCKQUOTE')[0].innerHTML);return false;" href="#comment">引用</a>
参数一的意思是在引用按钮代码的父级div(取最外围的div,如果是父级的父级,就要写两个parentNode.)中按顺序找到第一个cite标签(数列的序号是从0开始的,所以第一个也就是0),这里是先引用评论者的名称;参数二的意思是从引用按钮代码的父级div中按顺序找到第一个blockquote标签,这里引用的是评论内容。
PS:我已经尽可能说得很简单了,不明白再问吧。
相关推荐
- 微信小程序function函数arguments 是什么意思呢?
- 小程序和H5中canvas卡顿的性能优化方向和实践
- 微信小程序反编译报SyntaxError: Unexpected token ‘}‘ 不完美的解决方法
- 解决小程序反编译出现 app-service.js
- PHP把textarea中的回车换行替换为br
- zblogphp使用GetArticleList、GetList函数调用热门文章列表
- expose_php = On/Off,是干什么的?底层原理是什么?
- 淘宝给大家发6.5元新年购物红包啦,不要嫌少还有很多优惠,快来领取吧!
- Windows10 DVDRW识别为CD驱动解决方法,windows无法读取驱动器E:\中的光盘解决方法
- windows无法读取驱动器中的光盘(windows10)
- Zblog教程排行
- 最近发表