Ver Mensaje Individual
  #4 (permalink)  
Antiguo 03/01/2010, 11:15
Avatar de junihh
junihh
 
Fecha de Ingreso: febrero-2004
Ubicación: República Dominicana
Mensajes: 997
Antigüedad: 20 años, 2 meses
Puntos: 7
Respuesta: Seleccionar texto en TEXTAREA e INPUT-TEXT

Gracias por responder @Panino5001. Para dejar mas claro las cosas, aqui dejo mi script:

Código PHP:
function selectInnerTxt (tg,clsNm)
{
    
tg.toLowerCase ();
    var 
objs document.getElementsByTagName(tg);
    
//
    
for (var 0objs.lengthi++)
    {
       if ( 
String(objs[i].getAttribute('class')).indexOf(clsNm) != -)
       {
          
objs[i].title 'Click para copiar';
          
objs[i].onclick = function ()
          {
             if (
tg == 'input' || tg == 'textarea')
             {
                
this.select ();
             }
             if (
tg == 'div' || tg == 'span')
             {
                var 
range;
                if (
document.selection)
                {
                    
range document.body.createTextRange ();
                    
range.moveToElementText (this);
                    
range.select ();
                } else if (
window.getSelection)
                {
                    
range document.createRange ();
                    
range.selectNode (this);
                    
window.getSelection().addRange (range);
                }
             }
          }
       }
    }

A esa funcion le paso los parametros del tipo de tag a buscar en toda la pagina mas los objetos que tengan una clase en especifico. Como ves, esto afecta a todos los objetos en la pagina a partir de los parametros para hacerlo mas automatizado.

Como podria corregirlo para que no se borre el texto de los TEXTAREA e INPUT-TEXT ??. Alguna sugerencia ??. Muchas gracias por tu ayuda.
__________________
JuniHH
- Mi blog
- Mi portafolio