Ver Mensaje Individual
  #93 (permalink)  
Antiguo 15/01/2003, 14:55
Avatar de DanielRey
DanielRey
Usuario no validado
 
Fecha de Ingreso: enero-2001
Ubicación: Mendoza
Mensajes: 630
Antigüedad: 23 años, 9 meses
Puntos: 1
93 - Copiar el texto seleccionado

P: Copiar el texto que se ha seleccionado en la página.

R:
Código:
<!-- TWO STEPS TO INSTALL COPY SELECTED TEXT:

  1.  Copy the coding into the HEAD of your HTML document
  2.  Add the last code into the BODY of your HTML document  -->

<!-- STEP ONE: Paste this code into the HEAD of your HTML document  -->

<HEAD>

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->
<!-- Original:  Raul Macias ([email protected] ) -->
<!-- Web Site:  http://members.cox.net/raulhmacias/ -->
<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('select a text in the page and then press this button');
	}
}
//  End -->
</script>

</HEAD>

<!-- STEP TWO: Copy this code into the BODY of your HTML document  -->

<BODY>

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->
<!-- Original:  Raul Macias ([email protected] ) -->
<!-- Web Site:  http://members.cox.net/raulhmacias/ -->
<form name="it">

<p>This script allows you to select text on a web page and then copy it into a text box. Neat!</p>
<div align="center">
<input onclick="copyit(this.form.select1)" type="button" value="Press to copy the highlighted text" name="btnCopy">
<p>
<textarea name="select1" rows="4" cols="45"></textarea>
</div>
</form>

<p><center>
<font face="arial, helvetica" size"-2">Free JavaScripts provided<br>
by <a href="http://javascriptsource.com">The JavaScript Source</a></font>
</center><p>

<!-- Script Size:  1.69 KB -->

Última edición por DanielRey; 05/02/2003 a las 06:54