模仿IE自动完成功能_javascript技巧
程序员文章站
2022-05-16 22:42:45
...
// 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>
[Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]
Autocomplete Function
Power By Miracle, never-online
[Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]
推荐阅读
-
javascript suggest效果 自动完成实现代码分享_javascript技巧
-
JavaScript加入收藏夹功能(兼容IE、firefox、chrome)_javascript技巧
-
inputSuggest文本框输入时提示、自动完成效果(邮箱输入自动补全插件)_javascript技巧
-
javascript suggest效果 自动完成实现代码分享_javascript技巧
-
js实现连续英文字符自动换行兼容ie6 ie7和firefox_javascript技巧
-
关闭浏览器输入框自动补齐 兼容IE,FF,Chrome等主流浏览器_javascript技巧
-
JS仿百度搜索自动提示框匹配查询功能_javascript技巧
-
IE8 引入跨站数据获取功能说明_javascript技巧
-
关闭浏览器输入框自动补齐 兼容IE,FF,Chrome等主流浏览器_javascript技巧
-
用js实现输入提示(自动完成)的实例代码_javascript技巧