<script language=javascript>
function   shiftfocus()  
    {   var   keychar,fn,fesum,i,j,k,fsum;  
        var   fname=event.srcElement.name;  
        if(document.layers)   //ns  
          {   document.captureEvents(event.keydown);  
              kechar=event.which;  
          }  
        if(document.all)   //IE    
            keychar=event.keyCode;  
        if(keychar==13)  
        {   fsum=document.forms.length;  
            if(fname!=null)    
              {   for(i=0;i<fsum;i++)  
                  {   fesum=document.forms[i].elements.length;  
                      for(j=0;j<fesum;j++)  
                        {   if(fname==document.forms[i].elements[j].name)  
                              {   if(document.forms[i].elements[j].type=="textarea")  
                                          return;  
                                  if(document.forms[i].elements[j].type=="submit"||document.forms[i].elements[j].type=="reset"||document.forms[i].elements[j].type=="button")  
                                    {   document.forms[i].elements[j].click();  
                                        return   false;  
                                    }  
                                  k=j+1;    
                                  if(k>=fesum)  
                                      {   i++;  
                                          k=0;  
                                      }  
                                  if(i>=fsum)  
                                    {   i=0;  
                                        k=0;  
                                    }  
                                  for(;document.forms[i].elements[k].type=="hidden";k++);  
                                  document.forms[i].elements[k].focus();  
                                  if(document.forms[i].elements[k].type=="submit"||document.forms[i].elements[k].type=="reset"||document.forms[i].elements[k].type=="button")  
                                    {   document.forms[i].elements[k].click();  
                                        return   false;  
                                    }  
   
                                  return   false;  
                              }//if  
                        }//for  
                  }//for  
              }//if  
          document.forms[0].elements[0].focus();  
          return   false;  
      }//if  
  }//function    
  document.onkeydown=shiftfocus;
</script>
posted on 2007-07-06 14:35  绿蚂蚁  阅读(283)  评论(0编辑  收藏  举报