Foros del Web » Programando para Internet » Javascript »

Buscador Web e Iframes

Estas en el tema de Buscador Web e Iframes en el foro de Javascript en Foros del Web. Hola a todos. Vereis tengo una pagina A con un iframe llamado "contenido" que carga a su vez otra pagina B. En la pagína A ...
  #1 (permalink)  
Antiguo 23/12/2004, 11:41
 
Fecha de Ingreso: diciembre-2004
Mensajes: 15
Antigüedad: 19 años, 4 meses
Puntos: 0
Pregunta Buscador Web e Iframes

Hola a todos.

Vereis tengo una pagina A con un iframe llamado "contenido" que carga a su vez otra pagina B.
En la pagína A tengo un código para buscar texto dentro de un pagina web y posicionarse allí donde está el texto elegido. Ahí va el código:
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>
Bien la duda es la siguiente quiero que este código puede buscar en el iframe "contenido" que carga la pagina B y es donde quiero que busque el texto.
El código funciona bien dentro de la misma pagina.
Se ha entendido? Espero que sí. Sabe alguien alguna solución. Gracias. Un Saludo a todos.
  #2 (permalink)  
Antiguo 24/12/2004, 05:01
 
Fecha de Ingreso: diciembre-2004
Mensajes: 15
Antigüedad: 19 años, 4 meses
Puntos: 0
Bueno nadie conteSta, me siento solo ente inmenso oceano, pero da igual..

FELIZ NAVIDAD A TODOS....

p.d. sI ALGUIEN PUEDE AYUDARME?
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 22:06.