科学ニュースの商業版の中で使うajax空間と改ページ関数
7200 ワード
ビジネス版で使われているajax空間と改ページ関数は、彼らのjsコード学習がとてもいいです。 コントロールの機能 PageAjax(){ var xhrObj=null if(window.XMLtpRequest) { xhrObj=new XMLHttpRequest() } else if(window.ActiveXObject) { try{ xhrObj=new ActiveXObject(「Microsoft.XMLHTTP」); } catch(e 1) { try{ xhrObj=new ActiveXObject(「MSXML 2.XMLHTTP」); } catch(e 2){ try{ xhrObj=new ActiveXObject(「MSXML 3.XMLHTTP」); } catch(e 3){ alert(「Ajax作成失敗:」+e 3) } } } } else { alert(「識別できなかったブラウザ」) } return xhrObj;機能 Page(curPage、labelid、classide、installdir、url、refreshtype、specialid) { this.labelid=labelid; this.classid=classiid; this.url=url if (labelid.substring(0,5)=「{SQL_]」 { var slabelid.split(')[0]; slabelid=slabield.replace('、'); this.obj=「c_」+slabelid; this.p_obj=「p_」+slabelid; } else { this.obj=「c_」+labelid; this.p_obj=「p_」+labelid; } this.installdir=installdir; this.refshtype=refshtype; this.specialid=specialid; this.page=curPage loadData(1) } 機能 loadData(p){ this.page=p; var xhr=new PageAjax() xhr.open(「get」、installdir+url+「?」labelid=「+escape+」&classiid=「+classiid+」&refshtype=「+refshtype+」&specialid=" +specialid+"&curpage="+p,true); xhr.onreadystatechange=function (){ if(xhr.readyState==1) { if (p==1) eval('document.all.'+c_obj).innerHTML=" 次のページ 最後のページ ページ数: カラー=red>「+this.page+」/「+this.pagecount+」ページ "+this.perpagenum+this.itemunit+this.itemame+“/ページ”; break; case 2: statushtml=" 9 font face=webdings>7>“; var startpage=1 if (this.page==10) startpage=2 else if(this.page>10) startpage=eval((parseInt(this.page/10)*10+parseInt((this.page)%10)+2) for(var) i=startpagei<=this.pagecount;i+){ if (i==this.page) statushtml+=" [/color]「[/color]」「+i+」」 else statushtml+=" " n=n+1 if (n>10) break; } statushtml+="font face=webdings>8 font face=webdings>:>“; statushtml=""; break; case 4: statushtml=「共有」+this.pagecount+「ページ/」+this.com+this.itemunit+this.itement+this.itemaname+「 9 font face=webdings>7>“; for(var) i=this.pagei<=this.pagecount;i+){ if (i==this.page) statushtml+=< [/color]「[/color]」「+i+」」 else statushtml+="10) break; } statushtml+="font face=webdings>8 font face=webdings>:>“; break; case 3: statushtml="第 カラー[/color]「+this.page+」[/font]ページ 合計「+this.pagecount+」ページ > "+this.perpagenum+this.itemunit+this.itemame+“/ページ”; break; } statushtml+="第<セレクト name=\"goto\" on change=\"turn(parseInt)"\"""; for(var) i=1;i<=this.pagecount;i+){ if (i==this.page) statushtml+=<「 else statushtml+=<