2、 function getLeftPostion( theObj ) { var pos = 0; while ( theObj != null ) { pos += theObj.offsetLeft; //get the Object which contain theObj. theObj = theObj.offsetParent; } return pos; } function getTopPostion( theObj ) { var pos = 0; while ( theObj != null ) { pos += theObj.offsetTop; //get the Object which contain theObj. theObj = theObj.offsetParent; } return pos; } function checkVersion() { var isBadVersion=true; var curVer=navigator.appVersion; var pos=parseInt(curVer.indexOf("MSIE")); if (pos>=1) { var intVer=parseInt(curVer.charAt(pos+5)); if (intVer>=5) { isBadVersion=false;} } if (isBadVersion) { var msg="This page may not be displayed properly:\n"+ " This product requires Microsoft Internet Explorer 5 or later browser only."; alert(msg); } }
//check the browser version checkVersion();
// the array of comboBoies theArray = new Array();
//------------------------------------------------------------------------------------------------------ // create the text object //------------------------------------------------------------------------------------------------------ var txtObjIdName = objId + "_text";
if (document.all[txtObjIdName] != null) { strMsg="The following id: '" + txtObjIdName +"' is used internally by the Combo Box!\r\n"+ "Use of this id in your page may cause malfunction. Please use another id for your controls."; alert(strMsg); }
//------------------------------------------------------------------------------------------------------ // end //------------------------------------------------------------------------------------------------------
function doChange() { var idx = this.comObj.selectedIndex; var opt = this.comObj.options[idx]; this.txtObj.value = opt.text; this.txtObj.focus(); this.txtObj.select(); this.comObj.selectedIndex=-1; }
function getValue() { return this.txtObj.value; }
function doSelectIdx(i) { var optLen = 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 = ""; }
function focus() { this.txtObj.focus(); }
/*resize all combobox when window be resized*/ function resetAllSize() { var i; for (i=0; i < theArray.length; i++) { theArray[i].doResize(); } } ////////////////定位函数开始,我加的/////////////// function keyPress() { var txtStr; var comStr; var maxInt = 0; var defInt = 0; var defJ; txtStr = this.txtObj.value; //document.form1.test.value=txtStr; var j; for(j=0;j{ comStr = this.comObj.options[j].text; var m; for(m=0;m{ if(txtStr.charCodeAt(m) != comStr.charCodeAt(m)) { maxInt = m; break; } } if (defInt < maxInt) { defInt = maxInt; defJ = j; } } this.comObj.selectedIndex = defJ; }
查看所有0条评论>>