function createpagehtml(_npagecount, _ncurrindex, _spagename) { var pagestr = ""; var lastindex = _npagecount - 1; //最后一页 if (_npagecount == null || _npagecount <= 1) { return; } var ncurrindex = _ncurrindex || 0; pagestr += "首页 "; //首页 //上一页 if (ncurrindex == 0) pagestr += "上一页"; else{ if(ncurrindex==1){ pagestr += "上一页"; }else{ pagestr += "上一页"; } } //上一页 //点分页 if (lastindex <= 10) { if (ncurrindex == 0) pagestr += "1"; else pagestr += "1"; for (var i = 1; i < _npagecount; i++) { if (ncurrindex == i) pagestr += "" + (i + 1) + ""; else pagestr += "" + (i + 1) + ""; } } else { var n = 5; //设定前后显示几个 if (ncurrindex <= n) { if (ncurrindex == 0) pagestr += "1"; else pagestr += "1"; for (var i = 1; i < 10; i++) { if (ncurrindex == i) pagestr += "" + (i + 1) + ""; else pagestr += "" + (i + 1) + ""; } } else if (ncurrindex > _npagecount - n) { for (var i = _npagecount - 10; i < _npagecount; i++) { if (ncurrindex == i) pagestr += "" + (i + 1) + ""; else pagestr += "" + (i + 1) + ""; } } else { for (var i = ncurrindex - n; i < ncurrindex + n; i++) { if (ncurrindex == i) pagestr += "" + (i + 1) + ""; else pagestr += "" + (i + 1) + ""; } } } //点分页 //下一页 if (ncurrindex == lastindex) pagestr += "下一页"; else pagestr += "下一页  "; //下一页 pagestr += "尾页"//尾页 document.getelementbyid("pager").innerhtml = pagestr; }