|
来自Asp.net精英论坛:bbs.1aspx.com
<style>
* { font-size:10.2pt; font-family:tahoma; line-height:150%; } .divContent { border:1px solid red; background-color:#FFD2D3; width:500px; word-break:break-all; margin:10px 0px 10px; padding:10px; } </style> header <div id="divPagenation"></div> <div id="divContent"></div> footer <script language="jscript"> <!-- s="<p>女老师竭力 </p>"; function DHTMLpagenation(content) { with (this) { // client static html file pagenation this.content=content; this.contentLength=content.length; this.pageSizeCount; this.perpageLength=100; //default perpage byte length. this.currentPage=1; //this.regularExp=/.+[/?/&]page=(/d+)/; this.regularExp=//d+/; this.divDisplayContent; this.contentStyle=null; this.strDisplayContent=""; this.divDisplayPagenation; this.strDisplayPagenation=""; arguments.length==2?perpageLength=arguments[1]:''; try { divExecuteTime=document.createElement("DIV"); document.body.appendChild(divExecuteTime); } catch(e) { } if(document.getElementById("divContent")) { divDisplayContent=document.getElementById("divContent"); } else { try { divDisplayContent=document.createElement("DIV"); divDisplayContent.id="divContent"; document.body.appendChild(divDisplayContent); } catch(e) { return false; } } if(document.getElementById("divPagenation")) { divDisplayPagenation=document.getElementById("divPagenation"); } else { try { divDisplayPagenation=document.createElement("DIV"); divDisplayPagenation.id="divPagenation"; document.body.appendChild(divDisplayPagenation); } catch(e) { return false; } } DHTMLpagenation.initialize(); return this; }}; DHTMLpagenation.initialize=function() { with (this) { divDisplayContent.className=contentStyle!=null?contentStyle:"divContent"; if(contentLength<=perpageLength) { strDisplayContent=content; divDisplayContent.innerHTML=strDisplayContent; return null; } pageSizeCount=Math.ceil((contentLength/perpageLength)); DHTMLpagenation.goto(currentPage); DHTMLpagenation.displayContent(); }}; DHTMLpagenation.displayPage=function() { with (this) { strDisplayPagenation="分页:"; if(currentPage&¤tPage!=1) strDisplayPagenation+='<a href="javascript:void(0)" onclick="DHTMLpagenation.previous()">上一页</a> '; else strDisplayPagenation+="上一页 "; for(var i=1;i<=pageSizeCount;i++) { if(i!=currentPage) strDisplayPagenation+='<a href="javascript:void(0)" onclick="DHTMLpagenation.goto('+i+');">'+i+'</a> '; else strDisplayPagenation+=i+" "; } if(currentPage&¤tPage!=pageSizeCount) strDisplayPagenation+='<a href="javascript:void(0)" onclick="DHTMLpagenation.next()">下一页</a> '; else strDisplayPagenation+="下一页 "; strDisplayPagenation+="共 " + pageSizeCount + " 页,每页" + perpageLength + " 字符,调整字符数:<input type='text' value='"+perpageLength+"' id='ctlPerpageLength'><input type='button' value='确定' onclick='DHTMLpagenation.change(document.getElementById(/"ctlPerpageLength/").value);'>"; divDisplayPagenation.innerHTML=strDisplayPagenation; }}; DHTMLpagenation.previous=function() { with(this) { DHTMLpagenation.goto(currentPage-1); }}; DHTMLpagenation.next=function() { with(this) { DHTMLpagenation.goto(currentPage+1); }}; DHTMLpagenation.goto=function(iCurrentPage) { with (this) { startime=new Date(); if(regularExp.test(iCurrentPage)) { currentPage=iCurrentPage; strDisplayContent=content.substr((currentPage-1)*perpageLength,perpageLength); } else { alert("page parameter error!"); } DHTMLpagenation.displayPage(); DHTMLpagenation.displayContent(); }}; DHTMLpagenation.displayContent=function() { with (this) { divDisplayContent.innerHTML=strDisplayContent; }}; DHTMLpagenation.change=function(iPerpageLength) { with(this) { if(regularExp.test(iPerpageLength)) { DHTMLpagenation.perpageLength=iPerpageLength; DHTMLpagenation.currentPage=1; DHTMLpagenation.initialize(); } else { alert("请输入数字"); } }}; // method // DHTMLpagenation(strContent,perpageLength) DHTMLpagenation(s,1000); //--> </script> |
asp,php,asp.net长文章内容分页函数
最新推荐文章于 2025-05-07 15:44:38 发布
探讨了一种基于行数的网页长文章分页方法,该方法相较于按字数分页更为准确,但仍存在无法处理图文混排内容的问题。文中提出了一种新的思路,即使用固定高度的容器来判断内容是否超出并据此进行分页。

1166

被折叠的 条评论
为什么被折叠?



