
给访客查看文章时自动开始统计阅读文章多少分多少秒,很有意思的一个小功能
效果演示
![图片[1]-给访客加一个统计阅读文章时间博客网站文章适用-AA源码网 | 源码收藏](https://images.aaym.net/2024/01/20240116215821688-67833e6d3dcc2e65272cec691fa7004d_2022102416561396.jpg!/format/webp/lossless/true)
- 代码
- CSS
#tingliu{margin: 30px 0px 15px 0px; padding: 5px 0px 10px 0px; height: 100%; line-height: 2; text-align:center; font-size:14px; background: #F1E8DF; border: 1px dashed #CEB8A3; width: 100%; transition:all 0.2s ease-in-out 0s; -moz-transition:all 0.2s ease-in-out 0s;-webkit-transition:all 0.2s ease-in-out 0s;}
.tingliu2{color:#7C4500;} .tingliu3{color: #C03131;}
.tingliu5{position:relative; left:0px; top:5px;}
精简款
![图片[2]-给访客加一个统计阅读文章时间博客网站文章适用-AA源码网 | 源码收藏](https://images.aaym.net/2024/01/20240116220034336-decf68b516ba47a7cc8bb06cfefcb625_2022102416581916.png!/format/webp/lossless/true)
将以下代码加入到WordPress主题目录中的“文章页:single.php
”文件合适的位置。
Emlog应该是主题目录下的:echo_log.php
文件合适位置(图片需要下载出来)
<p style="text-align: center;"><img src="https://images.aaym.net/2024/01/20240116215914787-7619daa48b21a468e6ddef8455abd53e_2022102416572314.gif"</span> <span>您阅读这篇文章共花了:</span>
<span id="stime"></span>
<script language="JavaScript">var ss=0,mm=0,hh=0;function TimeGo(){ss++;if(ss>=60){mm+=1;ss=0}if(mm>=60){hh+=1;mm=0}ss_str=(ss<10?"0"+ss:ss);mm_str=(mm<10?"0"+mm:mm);
tMsg=""+hh+"小时"+mm_str+"分"+ss_str+"秒";document.getElementById("stime").innerHTML=tMsg;setTimeout("TimeGo()",1000)}TimeGo();</script></p>
本文结束END

© 版权声明
THE END
- 最新
- 最热
只看作者