<div class="codetitle"> <span><a style="CURSOR: pointer" data="21294" class="copybut" id="copybut21294" onclick="doCopy('code21294')"><u>复制代码</u></a></span> 代码如下:</div> <div class="codebody" id="code21294"> <br> <br> <br><script runat="server"> <BR></script> <br> <br> <br><title>无标题页</title> <br><script language="javascript" type="text/javascript"> <BR>function showpage(url,num,c_p) <BR>{ <BR>var prev=0;var next=0;var temp=0;var html=""; <BR>if(parseInt(c_p+3)>num) <BR>{ <BR>prev=num; <BR>} <BR>else <BR>{ <BR>prev=parseInt(c_p+3); <BR>} <BR>temp=10-(prev-c_p); <BR>if(c_p-temp>0) <BR>{ <BR>next=c_p-temp; <BR>} <BR>else <BR>{ <BR>next=1; <BR>} <BR>//如果显示的第一页<10,总页数又大于10 <BR>if(c_p+3<10&&num>c_p+3) <BR>{ <BR>for(j=1;j<=10-(c_p+3);j++) <BR>{ <BR>prev++; <BR>} <BR>} <BR>if(c_p!=num) <BR>{ <BR>html+="<a href='"+url+"index="+(1+c_p)+"'>上一页"+" "; <BR>} <BR>for (i=prev;i>=next;i--) <BR>{ <BR>if (i==c_p) <BR>{ <BR>html+="<font color=red>"+i+" "; <BR>} <BR>else <BR>{ <BR>html+="<a href='"+url+"index="+i+"'>"+i+""+" "; <BR>} <BR>} <BR>if(c_p!=1) <BR>{ <BR>html+="<a href='"+url+"index="+(c_p-1)+"'>下一页"+" "; <BR>} <BR>document.getElementById("pagenumber").innerHTML=html+" 转到<input id=\"page\" style=\"width: 33px\" />页 <input type=\"button\" value=\"go\" onclick=\"funcGo()\" />"; <BR>} <BR>function funcLoad() <BR>{ <BR>var num=100; <BR>var url="testpager.html?"; <BR>var index ; <BR>index = getUrlParam("index"); <BR>if(index==0) <BR>{ <BR>index=num; <BR>} <BR>showpage(url,num,index); <BR>} <BR>function getUrlParam(name) <BR>{ <BR>var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)"); <BR>var r = window.location.search.substr(1).match(reg); <BR>if (r!=null) <BR>{ <BR>return parseInt(unescape(r[2])); <BR>} <BR>return 0; <BR>} <BR>function funcGo() <BR>{ <BR>var num=100; <BR>if(parseInt(document.getElementById("page").value)>0&&parseInt(document.getElementById("page").value)<=num) <BR>{ <BR>window.location.href="testpager.html?index="+parseInt(document.getElementById("page").value); <BR>} <BR>else <BR>{ <BR>alert("页码不存在!"); <BR>return false; <BR>} <BR>} <BR></script> <br> <br> <br><form id="form1" runat="server"> <br><div id="pagenumber"> <br> </div> <br> </form> <br> <br> <br> </div>