Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
Olá
Estou adicionando eventos a text, funciona 100% no firefox, mas no IE não funciona... alguém sabe qual poderia ser o problema?
segue o código
<html>
<head>
<title>Teste evento</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script>
window.document.onmousemove = movimentacaoMouse;
var ok = false;
function buscaAliquota(objeto) {
objeto.value = '150';
}
function movimentacaoMouse(e) {
if(!ok) {
ok = true;
i = 0;
do {
i += 1;
campo = $('campo' + i.toString());
if(campo) {
adicionarEvento(campo,'change',function(e){buscaAliquota(this)} );
}
} while (campo);
}
}
function $(objeto) {
return document.getElementById(objeto);
}
function adicionarEvento(objeto, tipo, funcao){
try {
objeto.addEventListener(tipo, funcao, true);
} catch (e) {
try {
objeto.attachEvent('on' + tipo, funcao);
} catch (ee) {
alert(ee);
}
}
}
</script>
</head>
<body>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><input name="campo1" type="text" id="campo1"></td>
</tr>
<tr>
<td>
<input name="campo2" type="text" id="campo2"></td>
</tr>
<tr>
<td><input name="campo3" type="text" id="campo3"></td>
</tr>
</table>
</body>
</html>
VlwCarregando comentários...