日期:2014-05-16  浏览次数:20453 次

这个自动提示框为什么在ff用不了
ie正常ff就不正常

<script   language= "javascript ">
var   Class   =   {
    create:   function()   {
        return   function()   {
            this.initialize.apply(this,   arguments);
        }
    }
}

Object.extend   =   function(destination,   source)   {
    for   (var   property   in   source)   {
        destination[property]   =   source[property];
    }
    return   destination;
}

var   PromptList   =   Class.create();
PromptList.prototype   =   Object.extend(Object,   {
    initialize:   function(arrList,   idText,   idDiv)   {
this.aList   =   arrList.sort(this.SetSort);
this.oText   =   document.getElementById(idText);
this.oDiv   =   document.getElementById(idDiv);
var   o   =   this;
this.oText.onblur   =   function(){   PromptList.prototype.Hide.call(o)   };
this.oText.onkeyup   =   function(){   PromptList.prototype.Keyup.call(o)   };
this.oText.onfocus   =   function(){   PromptList.prototype.Show.call(o)   };
this.iIndex   =   -1;
    },
    //隐藏Div
    Hide   :   function(){
this.oDiv.style.display   =   'none ';
    },
    //排序函数
    SetSort:   function(a,   b){
if   (a.length   >   b.length)   return   1;
else   if   (a.length   ==   b.length)   return   a.localeCompare(b);
else   return   -1;
    },
    //检查Div
    CheckDiv:   function(){
if   (0   <   this.oDiv.children.length)   {   return   true;   }   else   {   this.Hide();   return   false;}
    },
    //输出
    Output   :   function(){
if(this.iIndex   > =   0){
this.oText.value   =   this.stripTags(this.oDiv.children[this.iIndex].innerHTML);
}
this.Hide();
    },
    //检查按键
    Keyup   :   function(e){
var   keyCode   =   (document.all)   ?   window.event.keyCode   :   e.charCode;
if   (keyCode   ==   40   ||   keyCode   ==   38){   //下上
var   isUp   =   (keyCode   ==   40)   ?   true   :   false;
if   (this.CheckDiv())   {   this.Move(isUp);   }
}else   if   (keyCode   ==   13){
this.Output();//回车
}else{   this.Show()   }
    },
    //检查显示
    Show   :   function(){
var   sValue   =   this.oText.value;
if   (sValue){
this.iIndex   =   -1;
this.oDiv.innerHTML   =   " ";
for   (var   i   =   0;   i   <   this.aList.length;   i++){
if(this.aList[i].toUpperCase().indexOf(sValue.toUpperCase())   > =   0){
this.Add(this.aList[i].replace(sValue,