Recherche dans un page html

lt_zuki Messages postés 4 Date d'inscription jeudi 5 février 2004 Statut Membre Dernière intervention 29 juin 2004 - 29 juin 2004 à 11:19
lt_zuki Messages postés 4 Date d'inscription jeudi 5 février 2004 Statut Membre Dernière intervention 29 juin 2004 - 29 juin 2004 à 11:58
Bonjour à tous,

voila je dois réaliser un petit glossaire. Et j'ai déjà un lien alphabétique mais je souhaiterais mettre un petit outil de recherche pour encore simplifier l'accés. Mon problème est que je ne comprends pas comment faire. J'ai lu bcp de tutoriels et trucs dans le genre. Mais c'était surtout des recherches dans un site par sur une page.
En effet je cherche qqc dans le style de l'outil recherche dans la page de ie, mozilla ou tout autre exploreur. Mais sans devoir aller dans Edit puis Find, je veux qqc dans un Frame.
Mon glossaire n'est pas sous forme d'une Bdd mais une grande page html ou une par lettre (pas encore défini) donc je sais pas comment faire.
On m'a indiqué que JScript serait le meilleur moyen donc je me tourne vers vous

Voila merci bcp de votre aide

1 réponse

lt_zuki Messages postés 4 Date d'inscription jeudi 5 février 2004 Statut Membre Dernière intervention 29 juin 2004
29 juin 2004 à 11:58
je viens de trouver comment chercher dans une page mais je n'arrive pas à gérer le pb des frames car mon outil de recherche est dans une frame et l'endroit on il doit chercher et dans une autre frame d'ou le pb.
Et je ne comprends pas comment changer de window pour aller vers l'autre frame ?
Le code est le suivant:
<script language="JavaScript">
/* Find In Page Script- By Mike Hall (MHall75819@aol.com) */
var NS4 = (document.layers); // Which browser?
var IE4 = (document.all);
var win = window; // window to search.
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);">

</form>
0
Rejoignez-nous