Ver Mensaje Individual
  #5 (permalink)  
Antiguo 01/04/2011, 10:10
adristb
 
Fecha de Ingreso: mayo-2010
Mensajes: 61
Antigüedad: 14 años
Puntos: 1
Respuesta: Recortar cadena de texto por pixeles

Gracias Panino por tu respuesta.

Pero si escribo eso me hace lo mismo que si pusiera un span, es decir, me lo pone en toda la linea y no me lo recorta.
Mi codigo es:

Código PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
<
html xmlns="http://www.w3.org/1999/xhtml"
<
head
<
meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> 
<
title>test</title
<
style>
div{display:inline;}
</
style>  
<
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(){ 
    
//alert(document.getElementById('ej').innerHTML);
    
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<2
            
t+=l[i].innerHTML
        else{
            if(
document.getElementById('ej').innerHTML.length>t.length)
            
t+='...';
            break;
        }
    } 
    
document.getElementById('ej').innerHTML=t

</script>   
</head> 

<body> 
Que puedo hacer??? gracias