Ver Mensaje Individual
  #1 (permalink)  
Antiguo 16/07/2010, 12:27
Mtf006
 
Fecha de Ingreso: julio-2010
Mensajes: 62
Antigüedad: 13 años, 10 meses
Puntos: 0
buscar texto en una pagina web

hola a todos..el asunto es este, mi cliente quiere un buscador de texto en su web...
quiere ( no se donde lo vio ) que en una caja de texto se ponga una palabra y se destaque esa palabra en la pagina si coincide la respuesta..
la cosa es q busque un kilo y encontre este codigo:



----------------------------------------------------------------------------------------------------------------------------------------------------------

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Documento sin título</title>
</head>
<!-- Inicia el Buscador ---- Blaizer-->
<SCRIPT language=JavaScript>
var NS4 = (document.layers);
var IE4 = (document.all);
var win = window;
var n = 0;
function findInPage(str) {
var txt, i, found;
if (str == "")
return false;
if (NS4) {
if (!win.find(str))
while(win.find(str, false, true))
n++;
else
n++;
if (n == 0)
alert("Not found.");
}
if (IE4) {
txt = win.document.body.createTextRange();
for (i = 0; i <= n && (found = txt.findText(str)) != false; i++) {
txt.moveStart("character", 1);
txt.moveEnd("textedit");
}
if (found) {
txt.moveStart("character", -1);
txt.findText(str);
txt.select();
txt.scrollIntoView();
n++;
}
else {
if (n > 0) {
n = 0;
findInPage(str);
}
else
alert("Su busqueda no produjo, ningun resultado. Intente con otro");
}
}
return false;
}
</SCRIPT>

<FORM name=search onsubmit="return findInPage(this.string.value);">
<P align=center><FONT size=3>
<INPUT
style="BORDER-RIGHT: #666666 1px solid; BORDER-TOP: #666666 1px solid; FONT-SIZE: 8pt; BORDER-LEFT: #666666 1px solid; BORDER-BOTTOM: #666666 1px solid"
onchange="n = 0;" size=16 name=string></FONT><BR><INPUT style="BORDER-RIGHT: #ffffff 1px solid; BORDER-TOP: #ffffff 1px solid; FONT-SIZE: 8pt; BORDER-LEFT: #ffffff 1px solid; BORDER-BOTTOM: #ffffff 1px solid; FONT-FAMILY: Tahoma; BACKGROUND-COLOR: #aaaaaa" type=submit value=Search in page ><center><font size=2pt;><font family=Times New Roman;><b>

<BR>
</P></FORM></DIV><BR><!-- Final Buscador-->
<body>
</body>
</html>

-----------------------------------------------------------------------------------------------------------------------------------------------------------------
PD: Como modifico el codigo para que sea leido en (Iexplorer -Firefox-Safari) o al menos en los exploradores mas usados?

el asunto es q no puedo encadenar el div con las palabras a buscar...
ejemplo la pagina contiene las siguientes palabras...
IVA
DESCUENTO
ENVIO
y esas palabras deberian resaltarse en color , o este codigo esta incorrecto?

alguna idea por aqui?!?!
gracias de antemano!