zoukankan      html  css  js  c++  java
  • IE、Firefox兼容Enter代替Tab的Javascript

     

    document.onkeydown=function(evt)
                  {
                   var isie = (document.all) ? true : false;
                   var key;
                   var srcobj;
                   if (isie)
                    {
                      key = event.keyCode;
                      srcobj=event.srcElement;
                      }
                   else
                    {
                      key = evt.which;
                      srcobj=evt.target;
                      }              
                     if(key==13 && srcobj.type!='button' && srcobj.type!='submit' &&srcobj.type!='reset' && srcobj.type!='textarea' && srcobj.type!='')                
                      {
                       if(isie)
                        {
                         event.keyCode=9;
                        }
                       else
                        {                       
                         var el=getNextElement(evt.target);
                                 if (el.type!='hidden')
                                     el.focus();
                                 else
                                    while (el.type=='hidden')
                                        el=getNextElement(el);
                                     el.focus();
                                 return false;
                        }
                      }
                   }               
                    function getNextElement (field) {
                       var form = field.form;
                       for (var e = 0; e < form.elements.length; e++) {
                         if (field == form.elements[e])
                             break;
                        }
                       return form.elements[++e % form.elements.length];
                      } 

    魔兽就是毒瘤,大家千万不要玩。
  • 相关阅读:
    堆(优先队列)模板
    线段树(递归)模板
    快速幂(含二阶方阵类)模板
    ACM/CF赛制getstart模板
    [Andrew Stankevich's Contest#21] Lempel-Ziv Compression
    [NOIP2001]Car的旅行路线
    [NOIP2007] 矩阵取数游戏
    [NOIP2010] 关押罪犯
    [NOIP1999] 拦截导弹
    设计模式之第1章-工厂方法模式(Java实现)
  • 原文地址:https://www.cnblogs.com/tracy/p/1797244.html
Copyright © 2011-2022 走看看