Ver Mensaje Individual
  #2 (permalink)  
Antiguo 28/03/2010, 14:15
Avatar de salbatore
salbatore
 
Fecha de Ingreso: abril-2007
Ubicación: Springfield
Mensajes: 1.567
Antigüedad: 17 años, 1 mes
Puntos: 19
Respuesta: como ingresar una tabulacion en vez de un cambio de foco?

Hola ed-209,

He buscado un poco por Google y he encontrado esto:

Código PHP:
<script>
function 
insertTab(oe)
{
    var 
kC e.keyCode e.keyCode e.charCode e.charCode e.which;
    if (
kC == && !e.shiftKey && !e.ctrlKey && !e.altKey)
    {
        var 
oS o.scrollTop;
        if (
o.setSelectionRange)
        {
            var 
sS o.selectionStart;
            var 
sE o.selectionEnd;
            
o.value o.value.substring(0sS) + "\t" o.value.substr(sE);
            
o.setSelectionRange(sS 1sS 1);
            
o.focus();
        }
        else if (
o.createTextRange)
        {
            
document.selection.createRange().text "\t";
            
e.returnValue false;
        }
        
o.scrollTop oS;
        if (
e.preventDefault)
        {
            
e.preventDefault();
        }
        return 
false;
    }
    return 
true;
}
</script>
<textarea onkeydown="insertTab(this, event);"></textarea> 
Puedes ver mas aqui, aunque no tiene un demo, lo he probado y funciona fantasticamente.

Hasta pronto!. Espero que te haya servido mi ayuda!.