簡単なjs区切りスクリプト

3019 ワード

 
  


<br>



<br>function showpage(url,num,c_p) <br>{ <br>var prev=0;var next=0;var temp=0;var html=""; <br>if(parseInt(c_p+3)>num) <br>{ <br>prev=num; <br>} <br>else <br>{ <br>prev=parseInt(c_p+3); <br>} <br>temp=10-(prev-c_p); <br>if(c_p-temp>0) <br>{ <br>next=c_p-temp; <br>} <br>else <br>{ <br>next=1; <br>} <br>// <10, 10 <br>if(c_p+3<10&&num>c_p+3) <br>{ <br>for(j=1;j<=10-(c_p+3);j++) <br>{ <br>prev++; <br>} <br>} <br>if(c_p!=num) <br>{ <br>html+="<a href='"+url+"index="+(1+c_p)+"'> </a>"+" "; <br>} <br>for (i=prev;i>=next;i--) <br>{ <br>if (i==c_p) <br>{ <br>html+="<font color=red>"+i+" </font>"; <br>} <br>else <br>{ <br>html+="<a href='"+url+"index="+i+"'>"+i+"</a>"+" "; <br>} <br>} <br>if(c_p!=1) <br>{ <br>html+="<a href='"+url+"index="+(c_p-1)+"'> </a>"+" "; <br>} <br>document.getElementById("pagenumber").innerHTML=html+" <input id=\"page\" style=\"width: 33px\" /> <input type=\"button\" value=\"go\" onclick=\"funcGo()\" />"; <br>} <br>function funcLoad() <br>{ <br>var num=100; <br>var url="testpager.html?"; <br>var index ; <br>index = getUrlParam("index"); <br>if(index==0) <br>{ <br>index=num; <br>} <br>showpage(url,num,index); <br>} <br>function getUrlParam(name) <br>{ <br>var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)"); <br>var r = window.location.search.substr(1).match(reg); <br>if (r!=null) <br>{ <br>return parseInt(unescape(r[2])); <br>} <br>return 0; <br>} <br>function funcGo() <br>{ <br>var num=100; <br>if(parseInt(document.getElementById("page").value)>0&&parseInt(document.getElementById("page").value)<=num) <br>{ <br>window.location.href="testpager.html?index="+parseInt(document.getElementById("page").value); <br>} <br>else <br>{ <br>alert(" !"); <br>return false; <br>} <br>} <br>