Ver Mensaje Individual
  #1 (permalink)  
Antiguo 13/05/2009, 13:47
Aimari
 
Fecha de Ingreso: noviembre-2008
Mensajes: 3
Antigüedad: 15 años, 6 meses
Puntos: 0
Buscador de texto

Hola, quisiera saber como se puede restringir la busqueda de texto en mi pagina web, ya que el codigo javascript que tengo te busca texto en toda la pagina y lo que deceo es que me busque en el cuerpo de la pagina y no la cabecera donde esta el logo y la barra de navegación.



Este es el codigo:

<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>

Hojala me puedan ayudar.

Aimari.