JavaScript - ayuda con este codigo!! buscador

 
Vista:

ayuda con este codigo!! buscador

Publicado por Roberto Kreuzz (1 intervención) el 01/04/2003 04:16:11
help- el siguiente codigo se trata de un pequeño busacdor de palabras dentro de una pagina, pero al darle enter para que siga buscando palabras iguales no se puede, lo que hago es regresarme hacia donde se encuentra el boton y volver a ponerle buscar y esto es algo molesto.

si alguien sabe lo ke tengo ke hacer por favor ayudeme. gracias.

codigo:<script language="JavaScript">


var NS4 = (document.layers);
var IE4 = (document.all);

var win = window; // Con frames usar top.nombre.window;
var n = 0;

function findInPage(str) {

var txt, i, found;

if (str == "")
return false;

// Find next occurance of the given string on the page, wrap around to the
// start of the page if necessary.

if (NS4) {

// Look for match starting at the current point. If not found, rewind
// back to the first match.

if (!win.find(str))
while(win.find(str, false, true))
n++;
else
n++;

// If not found in either direction, give message.

if (n == 0)
alert("Not found.");
}

if (IE4) {
txt = win.document.body.createTextRange();

// Find the nth match from the top of the page.

for (i = 0; i <= n && (found = txt.findText(str)) != false; i++) {
txt.moveStart("character", 1);
txt.moveEnd("textedit");
}

// If found, mark it and scroll it into view.

if %
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder