首页 > web前端 > js教程 > 正文

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

WBOY
发布: 2016-05-16 19:25:12
原创
848 人浏览过
// 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<_msg.length i if _i.append _f="true;" _i _i.display : alert not get instance e="=40" _i.directionkey else _c="0;" _o.childnodes _s="true;" window.onerror="new" function true>

Autocomplete Function

Power By Miracle, never-online

[Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]
相关标签:
来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板