Foros del Web » Programando para Internet » Javascript »

Buscar palabras

Estas en el tema de Buscar palabras en el foro de Javascript en Foros del Web. Hola: No tengo mucha idea de Javascript, pero saque de un programa este código Javascript para buscar palabras. No reconoce mayúsculas y minúsculas, pero si ...
  #1 (permalink)  
Antiguo 30/07/2004, 09:07
Avatar de satake  
Fecha de Ingreso: julio-2004
Mensajes: 140
Antigüedad: 19 años, 9 meses
Puntos: 0
Buscar palabras

Hola:
No tengo mucha idea de Javascript, pero saque de un programa este código Javascript para buscar palabras. No reconoce mayúsculas y minúsculas, pero si reconoce los acentos, yo necesito que no reconozca ni mayúsculas ni acentos.
Si alguien sabe como hacer esto por favor modifique el código y me lo envíe, através del foro o por mail a: [email protected]
Acá les envío el código:

<!-- Copiar dentro del tag BODY -->

<script language="JavaScript">

// By Mike Hall ([email protected])

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 (found) {
txt.moveStart("character", -1);
txt.findText(str);
txt.select();
txt.scrollIntoView();
n++;
}

// Otherwise, start over at the top of the page and find first match.

else {
if (n > 0) {
n = 0;
findInPage(str);
}

// Not found anywhere, give message.

else
alert("Not found.");
}
}

return false;
}

</script>

<form name="search" onSubmit="return findInPage(this.string.value);">
<font size="2"><p></font><font size="3"><input name="string" type="text" size="15"
onChange="n = 0;"></font> <input type="submit" value="Buscar"> </p>
</form>

  #2 (permalink)  
Antiguo 30/07/2004, 10:48
 
Fecha de Ingreso: abril-2004
Ubicación: México D.F.
Mensajes: 1.724
Antigüedad: 20 años
Puntos: 4
Prueba en buscar..

http://msdn.microsoft.com/library/de...s/findtext.asp
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 08:58.