Article display code in Thinkphp:
Copy the code code as follows:
<div id="showContent">{$article.content|htmlspecialchars_decode}</div>
<div id="articlePages"></div>
js implementation code:
Copy the code code as follows:
<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));
//Get the total number of pages, mainly by applying scrollHeight
pages.innerHTML="Total"+ all +"pages";
for(var i=1; i<=all;i++)
{
pages.innerHTML +=" <a href=/javascript:showPage('"+i+"');> "+i+"</a>";
//Output all page numbers
}
}
function showPage(pageIndex)
{
obj.scrollTop = (pageIndex-1)* parseInt(obj.offsetHeight);
}
</script>
css code:
Copy the code code as follows:
#showContent {
color:black;
font-size: 16px;
height: 700px;
overflow: hidden;
}
#articlePages {
text-align: right;
}