日期:2014-05-18  浏览次数:20686 次

求jsp长文章自动分页解决办法(有源码最好)
求jsp长文章自动分页解决办法(有源码最好)

------解决方案--------------------
顶一下!
------解决方案--------------------
支持下
------解决方案--------------------
顶一下 我也想知道
------解决方案--------------------
js 帮你搞定
下面代码直接用ie运行:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN ">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME= "Generator " CONTENT= "EditPlus ">
<META NAME= "Author " CONTENT= " ">
<META NAME= "Keywords " CONTENT= " ">
<META NAME= "Description " CONTENT= " ">
</HEAD>
<SCRIPT LANGUAGE= "JavaScript ">
<!--
var pageCount=0;
var nowPage=1;
var pageLine=10;//每页行数,可以调整
var text;
var totalLine=0;
var page=new Object();

function readText(){
text=document.getElementById( "text ").innerHTML;
var temp=text;
var count=0;
var line;
while(temp.indexOf( "\n ")> 0){
if(count==0) {
pageCount++;
eval( "page.page "+pageCount+ "=\ "\ " ");
}

totalLine++;
count++;
line=temp.substring(0,temp.indexOf( "\n "));
eval( "page.page "+pageCount+ "=page.page "+pageCount+ "+line+\ " <br> \ " ");

if(count> 9) count=0;
temp=temp.substring(temp.indexOf( "\n ")+1);
}
eval( "page.page "+pageCount+ "=page.page "+pageCount+ "+temp ");

}

function getStartPage(){
document.getElementById( "text ").innerHTML=page.page1;
}
function getEndPage(){
document.getElementById( "text ").innerHTML=eval( "page.page "+pageCount);
}
function getPage(p){
nowPage=nowPage+p;
if(nowPage <1) nowPage=1;
if(nowPage> pageCount) nowPage= pageCount;
document.getElementById( "text ").innerHTML=eval( "page.page "+nowPage);
}


//-->
</SCRIPT>
<BODY>
<pre id= "text ">
gggggggggg1
gggggggggg2
gggggggggg3
gggggggggg4
gggggggggg5
gggggggggg6
gggggggggg7
gggggggggg8
gggggggggg9
gggggggggg10
gggggggggg11
gggggggggg12
gggggggggg13
gggggggggg14
gggggggggg15
gggggggggg16
gggggggggg17
gggggggggg18
gggggggggg19
gggggggggg20
gggggggggg21
gggggggggg22
gggggggggg23
gggggggggg24
gggggggggg25
gggggggggg26
</pre>

<TABLE align=center>
<TR>
<TD> <A HREF= "javascript:getStartPage() "> 首页 </A> </TD>
<TD> <A HREF= "javascript:getPage(-1) "> 上一页 </A> </TD>
<TD> <A HREF= "javascript:getPage(1) "> 下一页 </A> </TD>
<TD> <A HREF= "javascript:getEndPage() "> 末页 </A> </TD>
</TR>
</TABLE>

</BODY> <SCRIPT LANGUAGE= "JavaScript ">
<!--
readText();
getStartPage();
//-->
</SCRIPT>
</HTML>



------解决方案--------------------