0

JavaScript関数を使用する別の方法を見つける必要があります。

var b = ce("input"); // Here I create element.
b.setAttribute("name", "g4");
b.value = "Centimetrais(pvz:187.5)";
b.onfocus = function() { remv(this); };
b.onchange = function() { abs(this); };
b.onkeypress = function() { on(event); }; // I need to change this place becose then I pass "event" argument function doesn't work.
ac(1, "", b); // Here I appendChild element in form.

関数は次のとおりです。

function on(evt) {
  var theEvent = evt|| window.event;
  var key = theEvent.keyCode || theEvent.which;
  key = String.fromCharCode( key );
  var regex = /^[0-9.,]+$/;
  if( !regex.test(key) ) {
    theEvent.returnValue = false;
    if(theEvent.preventDefault) theEvent.preventDefault();
  }
}

IEとChromeでは機能しますが、Mozillaではそうではありません。Firefoxのためにそれを修正する方法はありますか?

また、このパスでは、「car」、「dog」、this などの他の引数を渡すと、mozilla で動作する他の関数も表示されます。例えば:

firstFunction();
function firstFunction() {
var b = ce("input"); // Here I create element.
b.onkeypress = function() { on("hi!"); };
ac(1, "", b); // Here I appendChild element in form.
}
function on(evt) {
  alert(evt);
}
4

1 に答える 1