var newUrl; function getPager(url, sum, currnum, length,idTag) { newUrl =url; sum=parseInt(sum); currnum=parseInt(currnum); length=parseInt(length); if (length >= sum) { document.getElementById(idTag).innerHTML= ""; return ""; } var showsum = "共"; var showitem = "页"; var showfirstpage = "首页"; var showuppage = "<"; var shownextpage = ">"; var showlastpage = "尾页"; var showjump = "跳转到"; var showselect = "Go"; // var showtotal = "共"; // var showpage = "页"; var pagerinfo = ''; var sbinfo = ''; sbinfo+="
"; var pagenum = 0; if (sum % length == 0) { pagenum = sum / length; pagenum = parseInt(pagenum); } else { pagenum = sum / length-0 + 1; pagenum = parseInt(pagenum); } showfirstpage = "" +1; showlastpage = ""+pagenum; var first = ""; if (url.indexOf("?") != -1) { first = "&"; } else { first = "?"; } var pageUrl = ""; sbinfo+=(showsum + "" + pagenum + "" + showitem + "   "); if (1 == currnum) { sbinfo+=(showuppage + " "); } else { pageUrl = url + first + "currpage=" + (currnum - 1); sbinfo+=("" + showuppage + " "); } var firstUrl = url + first + "currpage=" + 1; sbinfo+=("" + showfirstpage + " "); var tempstr = ""; if (pagenum < 6) { var tag = 0; for (var i = 2; i < pagenum + 1 && i <= pagenum-1; i++) { pageUrl = url + first + "currpage=" + i; if (i == currnum) { tempstr = "" + i + " "; } else { tempstr = "" + i + " "; } sbinfo+=(tempstr); if(i>=pagenum-1){ tag = 1; } } } else if (currnum > pagenum - 1) { var tag = 0; sbinfo+=("..."); for (var i = currnum - 4; i < pagenum + 1 && i <= pagenum-1; i++) { pageUrl = url + first + "currpage=" + i; if (i == currnum) { tempstr = "" + i + " "; } else { tempstr = "" + i + " "; } sbinfo+=(tempstr); if(i>=pagenum-1){ tag = 1; } } } else if (currnum < 4) { var tag = 0; for (var i = 2; i < currnum + 3 && i <= pagenum-1; i++) { pageUrl = url + first + "currpage=" + i; if (i == currnum) { tempstr = "" + i + " "; } else { tempstr = "" + i + " "; } sbinfo+=(tempstr); if(i>=pagenum-1){ tag = 1; } } if(tag == 0){ sbinfo+=("..."); } } else { if(currnum - 2 > 2){ sbinfo+=("..."); }else{ } var tag = 0; for (var i = currnum - 2; i < currnum + 3 && i <= pagenum-1; i++) { pageUrl = url + first + "currpage=" + i; if (i == currnum) { tempstr = "" + i + " "; } else { tempstr = "" + i + " "; } sbinfo+=tempstr; if(i>=pagenum-1){ tag = 1; } } if(tag == 0){ sbinfo+=("..."); } } var endUrl = url + first + "currpage=" + pagenum; sbinfo+=(" " + showlastpage + " "); if (currnum == pagenum) { sbinfo+=(shownextpage); } else { pageUrl = url + first + "currpage=" + (currnum + 1); sbinfo+=("" + shownextpage + ""); } var selecturl = url + first; sbinfo+=(showjump + ""+""); sbinfo+=(""); pagerinfo = sbinfo; document.getElementById(idTag).innerHTML=pagerinfo; } function go(){ var tt= document.getElementById("goButton").value; var first = ""; if (newUrl.indexOf("?") != -1) { first = "&"; } else { first = "?"; } var listURL = newUrl+first+"currpage="+tt; // 跳转前将URL编码 listURL = encodeURI(listURL); window.location.href = listURL; }