zxjcn 发表于 2013-4-10 09:14:15

这样的分页代码怎么写?

这样的分页代码怎么写?求高人指点一下。

<script language="JavaScript" type="text/javascript">
var prestring = "http://fashion.zdface.com"
var urlstring = "/a/NewShow_"
var currentPage = 0
var prevPage = currentPage-1
var nextPage = currentPage+1
var countPage = 5
if(countPage>1&&currentPage!=0&&currentPage!=1)
document.write("<a href='" + prestring + urlstring + "1189695_1.htm'>首页</a>&nbsp;|&nbsp;<a href='" + prestring + urlstring + "1189695_"+ (prevPage +1)+ ".htm'>上一页</a>&nbsp;");
else if(countPage>1&&currentPage!=0&&currentPage==1)
document.write("<a href='" + prestring + urlstring + "1189695_1.htm'>首页</a>&nbsp;|&nbsp;<a href='" + prestring + urlstring + "1189695_"+ (prevPage +1)+ ".htm'>上一页</a>&nbsp;");
else
document.write("<a href='" + prestring + urlstring + "1189695_1.htm'>首页</a>&nbsp;|&nbsp;<a href='" + prestring + urlstring + "1189695_1.htm'>上一页</a>&nbsp;");
var num = 5;
for(var i=0+(currentPage-1-(currentPage-1)%num) ; i<=(num+(currentPage-1-(currentPage-1)%num))&&(i<countPage) ; i++){
if(currentPage==i)
document.write("<a style=\"color:#fff; background:#333;\" href='" + prestring + urlstring +"1189695_"+(i+1)+".htm'>"+(i+1)+"</a>&nbsp;");
else if(i==0){
document.write("<a href='" + prestring + urlstring + "1189695_1.htm'>"+1+"</a>&nbsp;");
}else
document.write("<a href='" + prestring + urlstring + "1189695_" + (i + 1) + "." + "htm'>"+(i+1)+"</a>&nbsp;");
}
if(countPage>1&&currentPage!=(countPage-1))
document.write("<a href='" + prestring + urlstring + "1189695_"+(nextPage+1)+ "."+"htm'>下一页</a>&nbsp;|&nbsp;<a href='" + prestring + urlstring + "1189695_"+countPage+ "."+"htm'>尾页</a>&nbsp;");
else
document.write("<a href='" + prestring + urlstring + "1189695_1.htm'>下一页</a>&nbsp;|&nbsp;<a href='" + prestring + urlstring + "1189695_"+countPage + ".htm'>尾页</a>&nbsp;");
</script>
&nbsp;

303718 发表于 2013-4-10 10:11:57

这种分页目前只能通过插件来采集到

www.sun002.com 发表于 2013-4-20 18:51:32

sunbin6ji 发表于 2014-1-15 10:20:18

分页目前只能通过插件来采集到
页: [1]
查看完整版本: 这样的分页代码怎么写?