日期:2013-09-20  浏览次数:20786 次

JS分页代码(BY AIRZEN modified 2004/05/13)

<Script Language="JavaScript" type="text/JavaScript" >
function showpage(url,num,c_p)
{
if (num<8)
{
stnum=num
}
else
{
stnum=8
}
for (i=1;i<=stnum;i++)
{
if (i==c_p){
document.write (i+" ");
}else{
document.write ("<a href='"+url+"&page="+i+"'>"+i+"</a>"+" ");
}
}
document.write ("..."+"<a href='"+url+"&page="+num+"'>"+num+"</a>"+" ");
}
</Script>

调用示例:
<Script Language="JavaScript" type="text/JavaScript" >
showpage("123.asp?id=5",10,5)
</Script>
<Script Language="JavaScript" type="text/JavaScript" >
showpage("123.asp?id=5",5,2)
</Script>