Foros del Web » Programando para Internet » Javascript »

AÑADIR SALTO DE LINEA A LA FUNCION copyit

Estas en el tema de AÑADIR SALTO DE LINEA A LA FUNCION copyit en el foro de Javascript en Foros del Web. Como se puede añadir un salto de linea a la funcion copyit de ete script <SCRIPT LANGUAGE="JavaScript"> <!-- Begin function copyit(theField) { var selectedText = ...
  #1 (permalink)  
Antiguo 01/12/2006, 08:06
 
Fecha de Ingreso: noviembre-2006
Ubicación: BARCELONA
Mensajes: 30
Antigüedad: 17 años, 5 meses
Puntos: 0
AÑADIR SALTO DE LINEA A LA FUNCION copyit

Como se puede añadir un salto de linea a la funcion copyit de ete script

<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function copyit(theField) {
var selectedText = document.selection;
if (selectedText.type == 'Text') {
var newRange = selectedText.createRange();
theField.focus();
theField.value += newRange.text;
} else {
alert('seleccione texto con el cursor i pulse este botón');
}
}
// End -->
</script>

<input onclick="copyit(this.form.select1)" type="button" value="Copiar en textarea" name="btnCopy">

<textarea rows="3" name="select1" cols="64" tabindex="4"></textarea>

para que el resultado NO sea : Texto1texto2texto3....

sino :

Texto1
Texto2
Texto3
  #2 (permalink)  
Antiguo 01/12/2006, 09:17
Avatar de JavierB
Colaborador
 
Fecha de Ingreso: febrero-2002
Ubicación: Madrid
Mensajes: 25.052
Antigüedad: 22 años, 2 meses
Puntos: 772
Hola CARLOS.asp

theField.value += newRange.text+'\n';

Saludos,
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 18:27.