Si alquien fuera tan amable de copiar y pegar este codigo y probarlo, quiero saber porque no funciona el FOCUS() en firefox.
Lo raro es que el ALERT() funciona perfectamente pero el focus no
Código Javascript
:
Ver original<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Crear elemento HTML</title>
<script type="text/javascript">
<!--
//CREAR PREGUNTA***************************************
var num=1;
function creaPreguntaSimple(){
var capa_preguntas = document.getElementById("preguntas");
var todo = capa_preguntas.innerHTML;
var div_preguntas = document.createElement("div");
div_preguntas.id='div_preguntas'+num;
div_preguntas.innerHTML ="<input type='text' id='preguntas"+num+"' onBlur='compruebaVacio("+num+");'>";
capa_preguntas.appendChild(div_preguntas);
num++;
}
function compruebaVacio(id){
alert("Despues de este ALERT() deberia hacer FOCUS() en el campo de texto, y no lo hace..........POR QUEEEEEEE ? POR QUE FUNCIONA EL ALERT Y NO EL FOCUS()");
document.getElementById('preguntas'+id).focus();
}
//-->
</script>
</head>
<body>
<div id="preguntas">
<input onClick="creaPreguntaSimple()" type="button" name="pregunta_simple" id="pregunta_simple" value="Crear Pregunta Simple">
</div>
</body>
</html>