Tema: Styles en IE
Ver Mensaje Individual
  #3 (permalink)  
Antiguo 02/03/2009, 23:57
Avatar de jeybi
jeybi
 
Fecha de Ingreso: julio-2008
Ubicación: Mexico
Mensajes: 130
Antigüedad: 15 años, 9 meses
Puntos: 10
Respuesta: Styles en IE

Me marca este error: (ie)

Invalid argument
Line: 51

No podria ser menos descriptivo...

Bueno en fin, aqui dejo el codigo completo, el codigo que intento debugear se comprende desde la linea 47 a la 51:

Código javascript:
Ver original
  1. function fade(id,tiempo,ancho,alto){
  2.     //Validamos argumentos de la funcion
  3.     id = typeof id == 'string'? document.getElementById(id):id;        //Obtenemos el elemento
  4.     ancho = typeof ancho == 'number'? ancho:id.offsetWidth;            //Si no se espeficia el ancho, usamos el del elemento actual
  5.     alto = typeof alto == 'number'? alto:id.offsetHeight;        //Si no se especifica el alto, usamos el del elemento actual
  6.    
  7.     //Declaramos nuestras variables
  8.     var tiemporef = ((tiempo*1000)-((tiempo*1000)*0.1));                               //El tiempo que tenemos disponible
  9.     var altoPlus = ((alto*0.9)/(((alto*0.9) * tiemporef) / ((alto*0.9)+ancho)))*10;   //Alto a aumentar en cada intervalo
  10.     var anchoPlus = (ancho/((ancho * tiemporef) / ((alto*0.9)+ancho)))*10;  //Ancho a aumentar en cada intervalo
  11.            
  12.     var anchoActual = 1;  //Ancho actual en todo momento
  13.     var altoActual = 1;   //Alto actual en todo momento
  14.     var opac = 0; //Opacidad en todo momento
  15.    
  16.     var horFade;  //Intervalo Horizontal
  17.     var verFade; //Intervalo Vertical    
  18.     var textFade; //Intervalo de texto
  19.    
  20.     var maxalto = alto*0.2; //Variaciones del alto
  21.     var maxaumento = maxalto/((tiempo*1000)*0.1)*10;   //Aumento en el primer round
  22.    
  23.     var posicion = id.style.position;  //Guardamos la posicion
  24.     var izq = id.style.left //Guardamos left atributo
  25.     var arr = id.style.top //Guardamos top atributo
  26.    
  27.     var xpos = id.offsetLeft+(ancho/2);  //Posicion nueva
  28.     var ypos = id.offsetTop+(alto/2);  //Posicion nueva
  29.    
  30.     var div = document.createElement('div'); //Creamos contenedor
  31.  
  32.     div.innerHTML = id.innerHTML;   //Le asignamos el contenido del elemento actual a nuestro contendor
  33.     id.innerHTML = '';           //Borramos el contenido de nuestro elemento actual
  34.    
  35.    
  36.     //Si tiene otro tipo de posicionamiento, creamos un pace holder
  37.     if(posicion != 'absolute'){
  38.         var spaceholder = document.createElement(id.tagName);  //Space-holder    
  39.                
  40.         for (i=0;i<id.attributes.length;i++){
  41.             if (id.attributes[i].specified){
  42.                 spaceholder.setAttribute(id.attributes[i].nodeName,id.attributes[i].value);
  43.             }
  44.         }
  45.        
  46.         //IE Styles
  47.         if(!id.getAttributeNode('style').nodeValue){
  48.             var iestyle = id.style;
  49.             for(k in iestyle)
  50.                 spaceholder.style[k] = id.style[k];            
  51.         }
  52.        
  53.         //Suprimimos cualquier background
  54.         spaceholder.style.background = 'none';
  55.        
  56.         //Insertamos el spaceholder
  57.         id.parentNode.insertBefore(spaceholder,id);
  58.     }
  59.    
  60.    
  61.     //Nuevos estilos al elemento
  62.     id.style.position = 'absolute';       //Sobreponemos este elemento al spaceholder, si existe
  63.     id.style.height = '1px';             //Inicia con un 1px al cuadrado
  64.     id.style.width = '1px';
  65.     id.style.left = xpos+'px';           //Le damos posicion
  66.     id.style.top = xpos+'px';            
  67.     id.style.display = 'block';          //Lo hacemos visible            
  68.    
  69.    
  70.     verFade= setInterval('fade.verFadeIt('+maxalto+','+maxaumento +')',10);   //Iniciamos cadena de intervalos
  71.    
  72.    
  73.         //Se encarga de la anchura
  74.     fade.horFadeIt= function(anchoaumento){
  75.         if(anchoActual+anchoaumento <= ancho){
  76.             id.style.width = (anchoActual+=anchoaumento)+'px';
  77.             if(xpos > 0)
  78.                 id.style.left = (xpos-=anchoaumento/2) +'px';
  79.         }
  80.         else{
  81.             id.style.width = (anchoActual=ancho)+'px';
  82.             clearInterval(horFade);    
  83.             verFade= setInterval('fade.verFadeIt('+alto+','+altoPlus+')',10);
  84.         }
  85.     }    
  86.        
  87.         //Se encarga de la altura
  88.     fade.verFadeIt = function(alturaMax,aumento){
  89.         if(altoActual+aumento <= alturaMax){
  90.             id.style.height = (altoActual+=aumento)+'px';
  91.             if(ypos > 0)
  92.                 id.style.top = (ypos-=aumento/2) +'px';
  93.         }
  94.         else {
  95.             id.style.height = (altoActual=alturaMax)+'px';
  96.             id.style.top = Math.round(ypos);
  97.             clearInterval(verFade);
  98.             if(anchoActual != ancho){
  99.                 horFade= setInterval('fade.horFadeIt('+anchoPlus+')',10);
  100.             }
  101.             else if(altoActual == alto){     //Llegando aqui hemos termiando la animacion, procedemos con el texto
  102.                 if(spaceholder)    id.parentNode.removeChild(spaceholder)  //Eliminamos el space holder, si existe
  103.                 id.style.position = posicion;  //Reposicionamos
  104.                 id.style.left = izq;
  105.                 id.style.top = arr;
  106.                 div.style.opacity = 0;          //Opacidad de nuestro contenido a cero
  107.                 div.style.zoom = 1; //IE HasLayout
  108.                 div.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=0)";
  109.                 id.appendChild(div);            //Insertamos contenido
  110.                 textFade = setInterval(fade.textFadeIt,tiempo*10);
  111.             }
  112.         }
  113.     }
  114.    
  115.     fade.textFadeIt = function(){
  116.         if(opac < 1){
  117.             div.style.opacity = (opac+=0.01);
  118.             div.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity='"+((opac+=0.01)*100)+")";
  119.         }
  120.         else{
  121.             clearInterval(textFade);
  122.         }
  123.     }
  124.    
  125. }

Lineas 47 - 51:

Código javascript:
Ver original
  1. if(!id.getAttributeNode('style').nodeValue){
  2.             var iestyle = id.style;
  3.             for(k in iestyle)
  4.                 spaceholder.style[k] = id.style[k];            
  5.         }


El HTML que uso (es solo como prueba):

Código HTML:
<html>
<head>    
    <script type="text/javascript" src="Log2.js"></script>
</head>
<body>
<input type="button" onclick="fade(document.getElementById('id1'),2)" value="Fade!" />
<div>Texto Texto Texto Texto Texto Texto Texto Texto Texto Texto Texto Texto Texto Texto Texto Texto Texto </div>
<div id="id1" style=" height:200px; background:blue; position:relative; bottom:10px; overflow:hidden"  >
<form method="aa" style="background:red; width:400px">
    <input type="text"  />
    <input type="radio" />
</form>
<div style="overflow:hidden"><img src="chapter06/example07/images/teacup05.jpg"  style="float:left"/>TFDGFDGFDGFDGFDG DGF DG FD FDGFDGFG FGFG FG FGF GFGFGG FGFGFGF GDHGFH FG
</div>
<div>Texto Texto Texto Texto Texto Texto Texto Texto Texto Texto Texto Texto Texto Texto Texto Texto Texto </div>
</body>
</html> 
Bueno gracias de todos modos, sigo buscando en el MSDN pero nada aun.

Saludos