Thinkphp中文章显示代码:
<div id=\"showContent\">{$article.content|htmlspecialchars_decode}</div>
<div id=\"articlePages\"></div>
js实现代码:
<script type=\"text/javascript\">
var obj = document.getElementById(\"showContent\");
var pages= document.getElementById(\"articlePages\");
//alert(obj.scrollHeight);
window.onload= function()
{
var all=Math.ceil(parseInt(obj.scrollHeight)/ parseInt(obj.offsetHeight));
//获取总页数,主要是应用scrollHeight
pages.innerHTML=\"共\"+ all +\"页\";
for(var i=1; i<=all;i++)
{
pages.innerHTML +=\" <a href=\\javascript:showPage(\'\"+i+\"\');> \"+i+\"</a> \";
//输出所有页码
}
}
function showPage(pageIndex)
{
obj.scrollTop = (pageIndex-1)* parseInt(obj.offsetHeight);
}
</script>
css代码:
#showContent {
color:black;
font-size: 16px;
height: 700px;
overflow: hidden;
}
#articlePages {
text-align: right;
}
本文地址:https://www.stayed.cn/item/12240
转载请注明出处。
本站部分内容来源于网络,如侵犯到您的权益,请 联系我