作者:小馄饨_奋斗 发表日期:2000年12月29日
有时候想在网页上使用客户端数据库,但为了兼容第版本的浏览器不支持xml技术,所以在此编了一些js的dml函数希望有兴趣的朋友一起讨论
function TRform()
{
this.TRRC=new Array();
this.QRC=new Array();//结果
this.currentRC=1;//当前纪录指针
this.lastRC=0;//最后纪录
this.RClength=arguments.length;//字段数
this.TRRC[0]=new Array();//字段名
for(i=0;i this.addRC=addRC; //加一条纪录 this.showRC=showRC;//打印当前纪录 this.showPrevious=showPrevious; this.showNext=showNext; this.preLoad=preLoad; //预装载图像 this.item2index=item2index;//使字段名到数组的索引 this.showThis=showThis; this.Isright=Isright; this.seek=seek; } function addRC() { this.TRRC[++this.lastRC]=new Array(); for(i=0;i return true; } function showRC(){ for(rc=0;rc { theEL=eval(this.QRC[0][rc]); if(this.QRC[0][rc].indexOf("image")==-1){ theEL.innerText=this.QRC[this.currentRC][rc] } else{ theEL.src=this.QRC[this.currentRC][rc]; } } return true; } function showNext(){ this.seek("all","all") if(++this.currentRC>this.lastRC) this.currentRC=this.lastRC; this.showRC(); } function showThis(){ this.seek("all","all") this.showRC(); } function showPrevious(){ this.seek("all","all"); if(--this.currentRC==0) this.currentRC=1; this.showRC(); } function preLoad(){ if(confirm('您需要先将图片载入内存吗,这样可以提高浏览时的平滑度.如果您的网络速度较慢的话,建议不要载入','明暗界限')){ status='图片装入中'; var imageIndex=new Array(); var n=0; for(i=0;i if(this.TRRC[0][i].indexOf("image")!=-1) imageIndex[n++]=i; } for (i=1;i<=this.lastRC;i++){ for(var II in imageIndex){ var preImage=new Image(); preImage.src=this.TRRC[i][II]; status+='.' } } } status=''; return true; } function item2index(item) { val=-1 for(i=0;i if(this.TRRC[0][i]==item) val=i; return val; } function Isright(rc,item,oper,exp) { id=this.item2index(item); ends=false; if(eval("this.TRRC[rc][id]"+oper+"exp")) ends=true; return ends; } function seek(exp1,item1) { var getexp=exp1.split("@"); this.QRC=new Array(); var n=0; var showitems=new Array(); if(item1=='all') for(i=0;i else{ for(i=1;i showitems[n++]=arguments[i]; } this.QRC[0]=new Array(); for(m=0;m { this.QRC[0][m]=showitems[m]; } for(m=0;m { showitems[m]=this.item2index(showitems[m]); } temp=1; if(getexp[0]=='all'){ for(k=1;k<=this.lastRC;k++) { this.QRC[temp++]=new Array(); for(i=0;i { this.QRC[temp-1][i]=this.TRRC[k][showitems[i]]; } } } else { for(k=1;k<=this.lastRC;k++) { if(this.Isright(k,getexp[0],getexp[1],getexp[2])) { this.QRC[temp++]=new Array(); for(i=0;i { this.QRC[temp-1][i]=this.TRRC[k][showitems[i]]; } } } } return this.QRC; } 【本文版权归作者与奥索网共同拥有,如需转载,请注明作者及出处】

