欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

js對文章內(nèi)容進(jìn)行分頁示例代碼

 更新時(shí)間:2014年03月05日 11:03:30   作者:  
這篇文章主要介紹了使用js對文章內(nèi)容進(jìn)行分頁的具體實(shí)現(xiàn),需要的朋友可以參考下
Thinkphp中文章顯示代碼:
復(fù)制代碼 代碼如下:

<div id="showContent">{$article.content|htmlspecialchars_decode}</div>
<div id="articlePages"></div>

js實(shí)現(xiàn)代碼:
復(fù)制代碼 代碼如下:

<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));
//獲取總頁數(shù),主要是應(yīng)用scrollHeight
pages.innerHTML="共"+ all +"頁";
for(var i=1; i<=all;i++)
{
pages.innerHTML +=" <a href=\javascript:showPage('"+i+"');> "+i+"</a>&nbsp;";
//輸出所有頁碼
}
}
function showPage(pageIndex)
{
obj.scrollTop = (pageIndex-1)* parseInt(obj.offsetHeight);
}
</script>

css代碼:
復(fù)制代碼 代碼如下:

#showContent {
color:black;
font-size: 16px;
height: 700px;
overflow: hidden;
}
#articlePages {
text-align: right;
}

相關(guān)文章

最新評論