Ver Mensaje Individual
  #3 (permalink)  
Antiguo 09/10/2008, 04:21
Avatar de Panino5001
Panino5001
Me alejo de Omelas
 
Fecha de Ingreso: mayo-2004
Ubicación: -34.637167,-58.462984
Mensajes: 5.148
Antigüedad: 20 años
Puntos: 834
Respuesta: cuantos lineas de texto tengo en un div?

Y así te evitás los testeos y funcionará en cualquier ubicación de la página:
Código PHP:
<html xmlns="http://www.w3.org/1999/xhtml">
<
head>
<
meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<
title>test</title>
<
script>
Array.
prototype.inArray=function(el){
    for(var 
i=0,l=this.length;i<l;i++)
        if(
this[i]==el)
            return 
true;
    return 
false;
}
onload=function(){
    var 
txt='<span>'+document.getElementById('ej').innerHTML.split('').join('</span><span>')+'</span>';
    
document.getElementById('ej').innerHTML=txt;
    var 
t='';
    var 
cuenta=[];
    for(var 
i=0l=document.getElementById('ej').getElementsByTagName('span'),ll=l.length;i<ll;i++){
        if(!
cuenta.inArray(l[i].offsetTop))
            
cuenta.push(l[i].offsetTop);
        if(
cuenta.length<6)
            
t+=l[i].innerHTML;
        else
            break;
    }
    
document.getElementById('ej').innerHTML=t;
}
</script>
</head>

<body><br />
<br />
<br />
<br />
<br />
<br />
<br />
<div id="ej" style="width:300px; height:200px;">Hola que tal necesito verdaderamente ayuda con esto!!!
Necesito cortar el texto a partir de la 5 ta linea de texto que tengo en un div, digamos q de la 6 ta linea inclusive en adelante lo tengo que cortar.
GRACIASHola que tal necesito verdaderamente ayuda con esto!!! Necesito cortar el texto
a partir de la 5 ta linea de texto que tengo en un div, digamos q de la 6 ta
linea inclusive en adelante lo tengo que cortar. GRACIAS</div>
</body>
</html> 

Última edición por Panino5001; 09/10/2008 a las 06:05