RE:definir color especifico a alguna palabra.
Saludos,
Un ejemplo adaptado:
<html>
<head>
<script>
/************************************************************
Find-in-page script
By Mark Wilton-Jones 11-12/10/2002
*************************************************************
Please see http://www.howtocreate.co.uk/jslibs/ for details and a demo of this script
Please see http://www.howtocreate.co.uk/jslibs/termsOfUse.html for terms of use
____________________________________________________________*/
function searchForText( toFind, frameToSearch ) {
if( !toFind ) { window.confirm( 'Teclea el texto' ); return; }
if( frameToSearch.focus ) { frameToSearch.focus(); }
if( window.find ) {
//Netscape compatible browsers provide the window.find method
if( document.layers ) {
//Against the JS spec, Netscape 4 will produce errors if too many arguments are given
var ifFound = frameToSearch.find( toFind, false, false );
} else {
var ifFound = frameToSearch.find( toFind, false, false, true, false, true, false );
}
} else if( frameToSearch.document.body && frameToSearch.document.body.createTextRange ) {
//IE or compatible use various TextRange features
if( frameToSearch.document.selection && frameToSearch.document.selection.type != 'None' ) {
//If some text is selected already (previous search or if they have selected it)
//make that the text range. Then move to the end of it to search beyond it
var theRange = frameToSearch.document.selection.createRange();
theRange.collapse( false );
} else {
//If no text is selected, start from the start of the document
var theRange = frameToSearch.document.forms[0].elements[0].createTextRange();
}
//find the next occurrence of the chosen string
var ifFound = theRange.findText( toFind );
if( ifFound && toFind == "select" || toFind == "sql" ) { theRange.select(); }
} else {
confirm ( 'Please use your browser\'s search facility' );
}
if( !ifFound ) { confirm ( 'Fin de la busqueda:\n' + toFind ); }
}
</script>
</head>
<body>
<SCRIPT language=javascript1.2 type=text/javascript>
if( document.body || window.find ) {
document.write( '<form action="" onSubmit="searchForText( this.elements[0].value, window ); return false;">'+
'<textarea onkeyup="searchForText( this.value, this ); return true;"></textarea></form>' );
}
</SCRIPT>
<p>Si tecleas texto que no sea (select ó sql) no ocurre nada.<br>Si tecleas al principio (select ó sql) quedará seleccionado.</p>
</body>
</html>
Se trata de un buscador de palabras en la página, adaptado para que busque en el textarea un texto concreto.
Tiene limitaciones, y algunas posibilidades que puedes ir probando. Por si arroja un poco más de luz al asunto.
Suerte.