function createPageHTML(_nPageCount, _nCurrIndex, _sPageName, _sPageExt){ if(_nPageCount == null || _nPageCount<=1){ return; } var nCurrIndex = _nCurrIndex || 0; if(nCurrIndex == 0) { document.write("
  • <
  • "); document.write("
  • 1
  • "); } else{ var prePageNum = nCurrIndex-1; if (prePageNum == 0) document.write("
  • <
  • "); else document.write("
  • <
  • "); document.write("
  • 1
  • "); } var startNum; var endNum; if (nCurrIndex -2 >1) startNum = nCurrIndex -2; else startNum = 1; if (nCurrIndex + 3 < _nPageCount) endNum = nCurrIndex + 3; else endNum = _nPageCount-1; if(startNum >1) document.write("
  • ...
  • "); for(var i = startNum; i"+(i+1) + ""); else document.write("
  • "+(i+1)+"
  • "); } if(endNum <_nPageCount-1) document.write("
  • ...
  • "); var nextPageNum = nCurrIndex+1; var lastPageNum = _nPageCount-1; if(nCurrIndex == _nPageCount-1) { document.write("
  • "+_nPageCount+"
  • "); document.write("
  • >
  • "); } else{ document.write("
  • "+_nPageCount+"
  • "); document.write("
  • >
  • "); } var currentNum = nCurrIndex+1; // document.write("
  • 共"+_nPageCount+"页,到第页
  • "); // document.write("  跳转"); } function gotoPage(nCount,sPageName, sPageExt) { console.log(nCount,sPageName, sPageExt) //判断是否为数字 var theNum=document.getElementById("gotopage").value; var re = /^(\+|-)?\d+($|\.\d+$)/; if(theNum<1){ location.href=sPageName + "."+sPageExt; }else if(theNum>nCount){ location.href=sPageName+"_" + (nCount-1) + "."+sPageExt; }else if(!re.test(theNum)){ alert("请输入页码"); return false; }else{ goNum = theNum-1; if (goNum == 0) location.href=sPageName + "."+sPageExt; else location.href=sPageName+"_" + goNum + "."+sPageExt; } }