Ver Mensaje Individual
  #13 (permalink)  
Antiguo 03/12/2010, 16:12
Avatar de truman_truman
truman_truman
 
Fecha de Ingreso: febrero-2010
Ubicación: /home/user
Mensajes: 1.341
Antigüedad: 14 años, 2 meses
Puntos: 177
Respuesta: focus() no funciona en firefox

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
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
  5. <title>Crear elemento HTML</title>
  6. <script type="text/javascript">
  7. <!--
  8. //CREAR PREGUNTA***************************************
  9. var num=1;
  10. function creaPreguntaSimple(){
  11.  
  12.     var capa_preguntas = document.getElementById("preguntas");
  13.     var todo = capa_preguntas.innerHTML;
  14.     var div_preguntas = document.createElement("div");
  15.    
  16.     div_preguntas.id='div_preguntas'+num;
  17.     div_preguntas.innerHTML ="<input type='text' id='preguntas"+num+"' onBlur='compruebaVacio("+num+");'>";
  18.     capa_preguntas.appendChild(div_preguntas);
  19.    
  20.    
  21.  num++;    
  22. }
  23. function compruebaVacio(id){
  24.         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()");
  25.         document.getElementById('preguntas'+id).focus();
  26. }
  27. //-->
  28. </script>
  29.  
  30. </head>
  31. <body>
  32. <div id="preguntas">
  33. <input onClick="creaPreguntaSimple()" type="button" name="pregunta_simple" id="pregunta_simple" value="Crear Pregunta Simple">
  34. </div>
  35. </body>
  36. </html>
__________________
la la la