Ver Mensaje Individual
  #2 (permalink)  
Antiguo 09/12/2012, 05:36
Avatar de emprear
emprear
Colaborador
 
Fecha de Ingreso: junio-2007
Ubicación: me mudé
Mensajes: 8.388
Antigüedad: 16 años, 10 meses
Puntos: 1567
Respuesta: Problema con ejecución de javascript en mozilla

Firefox necesita que le pases el objeto event como un argumento, líneas 26 y 40, y luego tufuncion(e)

Código HTML:
Ver original
  1.  
  2.  
  3. <style type="text/css">
  4.  
  5.     .objMovible { position:absolute; cursor:pointer }
  6.  
  7.  
  8. <script type="text/javascript">
  9.  
  10.     var estoyArrastrando = false;
  11.     var obj;
  12.     var obj1;
  13.     var a_des;
  14.     var p_des;
  15.     var pos_obj;
  16.     var pos_obj_1;
  17.  
  18.     function presionarBoton(e) {
  19.  
  20.         estoyArrastrando = true;
  21.         obj = document.getElementById('div_');
  22.         obj1 = document.getElementById('div_1');
  23.         e = window.event || e;
  24.        
  25.         a_des = e.clientX;
  26.         pos_obj = parseInt(obj.style.left);
  27.         pos_obj_1 = parseInt(obj1.style.left);
  28.         return false;
  29.  
  30.     }
  31.  
  32.     document.onmousedown = presionarBoton;
  33.  
  34.     function arrastrarRaton(e){
  35.  
  36.         if (estoyArrastrando) {
  37. e = window.event || e;
  38.             p_des = e.clientX;
  39.  
  40.             if (((pos_obj>0)&&(pos_obj_1>0))||((pos_obj<0)&&(pos_obj_1<0))) {
  41.  
  42.                 obj.style.left = (p_des - a_des) + pos_obj;
  43.                 obj1.style.left = (p_des - a_des) + pos_obj_1;
  44.  
  45.             } else {
  46.  
  47.                 obj.style.left = (p_des - a_des);
  48.                 obj1.style.left = (p_des - a_des);
  49.  
  50.             }
  51.  
  52.             return false;
  53.  
  54.         }
  55.  
  56.     }
  57.  
  58.     document.onmousemove = arrastrarRaton;
  59.  
  60.     function soltarBoton() {   
  61.  
  62.         estoyArrastrando = false;
  63.  
  64.     }
  65.  
  66.     document.onmouseup = soltarBoton;
  67.  
  68.  
  69. </head>
  70.  
  71.  
  72. <div  id="div_" class="objMovible" style="top:200px;width:200px;height:20px;background-color:#CC0000"></div>
  73. <div  id="div_1" class="objMovible" style="width:200px;height:20px;background-color:#CC0000"></div>
  74.  
  75. </body>
  76. </html>
Saludos
__________________
La voz de las antenas va, sustituyendo a Dios.
Cuando finalice la mutación, nueva edad media habrá
S.R.