0
자바 스크립트 함수를 사용하는 다른 방법을 찾아야합니다. 여기 자바 스크립트 함수에 DOM 전달 인수
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.
는 기능입니다 : 작동 IE에서
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();
}
}
크롬하지만 모질라하지 않습니다. 어떤 대안 파이어 폭스에 대한 수정 방법?
"car", "dog"와 같은 다른 인수를 전달하면이 경로에서 다른 함수가 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);
}
당신은'b.onkeypress = function (event) {on (event); };'? – nnnnnn
아니요. 시도하지 않았어. – WVW
예, 작동합니다. :) 고맙습니다. – WVW