|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
问题是他们究竟是喜欢他们是使用软件时,速度快还是速度慢好.(当然在3秒以内).无论是他们输入资料时,查找资料时,分析资料时.下拉菜单撑持输出,并依据输出内容主动定位:
参考:演员宣布于10/23/20018:58:16AM的文章“罗亭的可输出下拉框的解密简化版.”,在此出格感激相干人等。
本文为这个下拉框增添了一点小小的功效:输出可以定位在已有的选择框内。另有一个弱点,列位给改改:输出的时分不克不及够主动拉开选择框,怎样办?
functiongetLeftPostion(theObj)
{
varpos=0;
while(theObj!=null)
{
pos+=theObj.offsetLeft;
//gettheObjectwhichcontaintheObj.
theObj=theObj.offsetParent;
}
returnpos;
}
functiongetTopPostion(theObj)
{
varpos=0;
while(theObj!=null)
{
pos+=theObj.offsetTop;
//gettheObjectwhichcontaintheObj.
theObj=theObj.offsetParent;
}
returnpos;
}
functioncheckVersion()
{
varisBadVersion=true;
varcurVer=navigator.appVersion;
varpos=parseInt(curVer.indexOf("MSIE"));
if(pos>=1)
{
varintVer=parseInt(curVer.charAt(pos+5));
if(intVer>=5)
{isBadVersion=false;}
}
if(isBadVersion)
{
varmsg="Thispagemaynotbedisplayedproperly:
"+
"ThisproductrequiresMicrosoftInternetExplorer5orlaterbrowseronly.";
alert(msg);
}
}
//checkthebrowserversion
checkVersion();
//thearrayofcomboBoies
theArray=newArray();
functioncombobox(objId,objHandler)
{
this.comObj=document.all[objId];
this.comObj.selectedIndex=-1;
this.getValue=getValue;
this.doResize=doResize;
this.doChange=doChange;
this.loseFocus=loseFocus;
this.doSelectIdx=doSelectIdx;
this.focus=focus;
this.keyPress=keyPress;
this.change=change;
varstrMsg="";
//------------------------------------------------------------------------------------------------------
//createthetextobject
//------------------------------------------------------------------------------------------------------
vartxtObjIdName=objId+"_text";
if(document.all[txtObjIdName]!=null)
{
strMsg="Thefollowingid:"+txtObjIdName+"isusedinternallybytheComboBox!
"+
"Useofthisidinyourpagemaycausemalfunction.Pleaseuseanotheridforyourcontrols.";
alert(strMsg);
}
vartxtInner="<INPUTtype=textid="+txtObjIdName+"name="+txtObjIdName+"onblur="+objHandler+".loseFocus()"+"onkeyup="+objHandler+".keyPress()"+"onchange="+objHandler+".keyPress()"+"style=display:none;position:absolutevalue=>";
this.comObj.insertAdjacentHTML("afterEnd",txtInner);
this.txtObj=document.all[txtObjIdName];
//------------------------------------------------------------------------------------------------------
//end
//------------------------------------------------------------------------------------------------------
this.beResizing=false;
this.doResize();
theArray[theArray.length]=this;
}
functionloseFocus()
{
vartheComObj=this.comObj;
vartheTxtObj=this.txtObj;
vari;
theComObj.selectedIndex=-1;
if(theTxtObj.value=="")
{
return;
}
varoptLen=theComObj.options.length;
for(i=0;i<optLen;i++)
{
varcomVal=theComObj.options[i].text;
vartxtVal=theTxtObj.value;
if(comVal==txtVal)
{
theComObj.selectedIndex=i;
return;
}
}
}
functiondoResize()
{
if(!this.beResizing)
{
this.beResizing=true;
this.txtObj.style.display="none";
this.comObj.style.position="static";
this.txtObj.style.posLeft=getLeftPostion(this.comObj);
this.txtObj.style.posTop=getTopPostion(this.comObj)+1;
this.txtObj.style.posWidth=this.comObj.offsetWidth-16;
this.txtObj.style.posHeight=this.comObj.offsetHeight;
this.comObj.style.position="absolute";
this.comObj.style.posLeft=this.txtObj.style.posLeft;
this.comObj.style.posTop=this.txtObj.style.posTop;
this.offWidth=this.comObj.offsetWidth;
varstrRect="rect(0"+(this.comObj.offsetWidth)+""+this.comObj.offsetHeight+""+(this.txtObj.style.posWidth-2)+")";
this.comObj.style.clip=strRect;
this.txtObj.style.display="";
this.beResizing=false;
}
}
functiondoChange()
{
varidx=this.comObj.selectedIndex;
varopt=this.comObj.options[idx];
this.txtObj.value=opt.text;
this.txtObj.focus();
this.txtObj.select();
this.comObj.selectedIndex=-1;
}
functiongetValue()
{
returnthis.txtObj.value;
}
functiondoSelectIdx(i)
{
varoptLen=this.comObj.options.length;
if((i>=0)&&(i<optLen))
{
this.comObj.selectedIndex=i;
this.txtObj.value=this.comObj.options[i].text;
return;
}
this.txtObj.value="";
}
functionfocus()
{
this.txtObj.focus();
}
/*resizeallcomboboxwhenwindowberesized*/
functionresetAllSize()
{
vari;
for(i=0;i<theArray.length;i++)
{
theArray[i].doResize();
}
}
////////////////定位函数入手下手,我加的///////////////
functionkeyPress()
{
vartxtStr;
varcomStr;
varmaxInt=0;
vardefInt=0;
vardefJ;
txtStr=this.txtObj.value;
//document.form1.test.value=txtStr;
varj;
for(j=0;j<this.comObj.options.length;j++)
{
comStr=this.comObj.options[j].text;
varm;
for(m=0;m<txtStr.length+1;m++)
{
if(txtStr.charCodeAt(m)!=comStr.charCodeAt(m))
{
maxInt=m;
break;
}
}
if(defInt<maxInt)
{
defInt=maxInt;
defJ=j;
}
}
this.comObj.selectedIndex=defJ;
}
asp可以使用微软的activeX使得网页功能无比强大,不过安全性也较差,而且是基于的windows服务器,所以性能稳定性也一般 |
|