Code displayed in Thinkphp:
Copy codeThe Code is as follows:
<Div id = "showContent" >{$ article. content | htmlspecialchars_decode} </div>
<Div id = "articlePages"> </div>
Js implementation code:
Copy codeThe Code is 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 ));
// Obtain the total number of pages, mainly by applying scrollHeight
Pages. innerHTML = "Total" + all + "page ";
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 codeThe Code is as follows:
# ShowContent {
Color: black;
Font-size: 16px;
Height: 700px;
Overflow: hidden;
}
# ArticlePages {
Text-align: right;
}