您好,欢迎访问一九零五行业门户网

模仿IE自动完成功能_javascript技巧

new document
// var autocomplete = new jsauto(autocomplete,divautocomplete) // handle event: // autocomplete.handleevent(value, returnobjectid) // // step2 : // add autocompete item: // autocomplete.item(string) // string must be a string var, you can split the string by , // autocomplete.item(bluedestiny,never-online,csdn,blueidea) // http://www.never-online.com function jsauto(instancename,objid) { this._msg = []; this._x = null; this._o = document.getelementbyid( objid ); if (!this._o) return; this._f = null; this._i = instancename; this._r = null; this._c = 0; this._s = false; this._v = null; this._o.style.visibility = hidden; this._o.style.position = absolute; this._o.style.zindex = 9999; return this; }; jsauto.prototype.directionkey=function() { with (this) { var e = _e.keycode ? _e.keycode : _e.which; var l = _o.childnodes.length; (_c>l-1 || _c= l-1) ? _c=0 : _c ++; _o.childnodes[_c].classname=mouseover; } if( e==38 && _s ) { _o.childnodes[_c].classname=mouseout; _c--0 ) { var arrmsg=msg.split(,); for(var i=0; i$1); div.style.fontfamily = verdana; _o.appendchild(div); }}; jsauto.prototype.display=function() { with(this) { if(_f&&_v!=) { _o.style.left = _r.offsetleft; _o.style.width = _r.offsetwidth; _o.style.top = _r.offsettop + _r.offsetheight; _o.style.visibility = visible; } else { _o.style.visibility=hidden; } }}; jsauto.prototype.handleevent=function(fvalue,fid,event) { with (this) { var re; _e = event; var e = _e.keycode ? _e.keycode : _e.which; _x = []; _f = false; _r = document.getelementbyid( fid ); _v = fvalue; _i = eval(_i); re = new regexp(^ + fvalue + , i); _o.innerhtml=; for(var i=0; i
autocomplete function
power by miracle, never-online
[ctrl+a 全选 注:如需引入外部js需刷新才能执行]
其它类似信息

推荐信息