Join the AMA (Ask Me Anything) with the Firefox leadership team to celebrate Firefox 20th anniversary and discuss Firefox’s future on Mozilla Connect. Mark your calendar on Thursday, November 14, 18:00 - 20:00 UTC!

Az oldal korlátolt funkcionalitással fog rendelkezni, amíg elvégezzük a felhasználói élményt javító karbantartást. Ha egy leírás nem oldja meg a problémáját, és kérdést tenne fel, akkor a támogatási közösségünk a @FirefoxSupport Twitter oldalon tud segíteni, vagy az /r/firefox oldalon a Redditen.

Támogatás keresése

Kerülje el a támogatási csalásokat. Sosem kérjük arra, hogy hívjon fel egy telefonszámot vagy osszon meg személyes információkat. Jelentse a gyanús tevékenységeket a „Visszaélés bejelentése” lehetőséggel.

További tudnivalók

A témacsoportot lezárták és archiválták. Tegyen fel új kérdést, ha segítségre van szüksége.

Firefox 23 - Key Event dosen't work

  • 4 válasz
  • 4 embernek van ilyen problémája
  • 2 megtekintés
  • Utolsó üzenet ettől: Marcio Cardozo

more options

After I installed firefox 23 javascript function used to make a mask entry fields stopped working. Until version 22 function worked.

MaskInput = function(f, m){
 function mask(e){
  var patterns = {"1": /[A-Z]/i, "2": /[0-9]/, "4": /[À-ÿ]/i, "8": /./, "16": /^[-]?(\d{0,99})?$/ },
   rules = { "a": 3, "A": 7, "9": 2, "C":5, "c": 1, "*": 8, "0": 16};
  function accept(c, rule){
   for(var i = 1, r = rules[rule] || 0; i <= r; i<<=1)
    if(r & i && patterns[i].test(c))
     break;
    return i <= r || c == rule;
  }
  var k, mC, r, c = String.fromCharCode(k = e.key), l = f.value.length;
  (!k || k == 8 ? 1 : (r = /^(.)\^(.*)$/.exec(m)) && (r[0] = r[2].indexOf(c) + 1) + 1 ?
   r[1] == "O" ? r[0] : r[1] == "E" ? !r[0] : accept(c, r[1]) || r[0]
   : (l = (f.value += m.substr(l, (r = /[A|9|C|\*]/i.exec(m.substr(l))) ?
   r.index : l)).length) < m.length && accept(c, m.charAt(l))) || e.preventDefault();
 }
 for(var i in !/^(.)\^(.*)$/.test(m) && (f.maxLength = m.length), {keypress: 0, keyup: 1})
  addEventMask(f, i, mask);
};

addEventMask = function(o, e, f, s){
    var r = o[r = "_" + (e = "on" + e)] = o[r] || (o[e] ? [[o[e], o]] : []), a, c, d;
    r[r.length] = [f, s || o], o[e] = function(e){
        try{
            (e = e || event).preventDefault || (e.preventDefault = function(){e.returnValue = false;});
            e.stopPropagation || (e.stopPropagation = function(){e.cancelBubble = true;});
            e.target || (e.target = e.srcElement || null);
            e.key = (e.which + 1 || e.keyCode + 1) - 1 || 0;
        }catch(f){}
        for(d = 1, f = r.length; f; r[--f] && (a = r[f][0], o = r[f][1], a.call ? c = a.call(o, e) : (o._ = a, c = o._(e), o._ = null), d &= c !== false));
        return e = null, !!d;
    }
};

removeEventMask = function(o, e, f, s){
    for(var i = (e = o["_on" + e] || []).length; i;)
        if(e[--i] && e[i][0] == f && (s || o) == e[i][1])
            return delete e[i];
    return false;
};
After I installed firefox 23 javascript function used to make a mask entry fields stopped working. Until version 22 function worked. <pre><nowiki>MaskInput = function(f, m){ function mask(e){ var patterns = {"1": /[A-Z]/i, "2": /[0-9]/, "4": /[À-ÿ]/i, "8": /./, "16": /^[-]?(\d{0,99})?$/ }, rules = { "a": 3, "A": 7, "9": 2, "C":5, "c": 1, "*": 8, "0": 16}; function accept(c, rule){ for(var i = 1, r = rules[rule] || 0; i <= r; i<<=1) if(r & i && patterns[i].test(c)) break; return i <= r || c == rule; } var k, mC, r, c = String.fromCharCode(k = e.key), l = f.value.length; (!k || k == 8 ? 1 : (r = /^(.)\^(.*)$/.exec(m)) && (r[0] = r[2].indexOf(c) + 1) + 1 ? r[1] == "O" ? r[0] : r[1] == "E" ? !r[0] : accept(c, r[1]) || r[0] : (l = (f.value += m.substr(l, (r = /[A|9|C|\*]/i.exec(m.substr(l))) ? r.index : l)).length) < m.length && accept(c, m.charAt(l))) || e.preventDefault(); } for(var i in !/^(.)\^(.*)$/.test(m) && (f.maxLength = m.length), {keypress: 0, keyup: 1}) addEventMask(f, i, mask); }; addEventMask = function(o, e, f, s){ var r = o[r = "_" + (e = "on" + e)] = o[r] || (o[e] ? [[o[e], o]] : []), a, c, d; r[r.length] = [f, s || o], o[e] = function(e){ try{ (e = e || event).preventDefault || (e.preventDefault = function(){e.returnValue = false;}); e.stopPropagation || (e.stopPropagation = function(){e.cancelBubble = true;}); e.target || (e.target = e.srcElement || null); e.key = (e.which + 1 || e.keyCode + 1) - 1 || 0; }catch(f){} for(d = 1, f = r.length; f; r[--f] && (a = r[f][0], o = r[f][1], a.call ? c = a.call(o, e) : (o._ = a, c = o._(e), o._ = null), d &= c !== false)); return e = null, !!d; } }; removeEventMask = function(o, e, f, s){ for(var i = (e = o["_on" + e] || []).length; i;) if(e[--i] && e[i][0] == f && (s || o) == e[i][1]) return delete e[i]; return false; };</nowiki></pre>

Módosította: cor-el,

Kiválasztott megoldás

After I debug the code I found the solution, in Firefox 22 e.key works but in Firefox 23 this attribute does not work, then switched e.key by e.charCode

Válasz olvasása eredeti szövegkörnyezetben 👍 0

Összes válasz (4)

more options

Try posting at the Web Development / Standards Evangelism forum at MozillaZine. The helpers over there are more knowledgeable about web page development issues with Firefox.
http://forums.mozillazine.org/viewforum.php?f=25
You'll need to register and login to be able to post in that forum.

more options

Thanks for the reply, but I would like to know if there are any bug in the FF23 Key Event, because the behavior change in the last version ?

The same javascript is used since Firefox 3, only now started to not work.

more options

I might be necessary to define functions before referencing to them, so you can try to define addEventMask() before function mask(e) which calls this function.

You can check the Browser/Error Console (Firefox/Tools > Web Developer;Ctrl+Shift+J) for errors.

more options

Kiválasztott megoldás

After I debug the code I found the solution, in Firefox 22 e.key works but in Firefox 23 this attribute does not work, then switched e.key by e.charCode