bonjour !

je suis à la recherche d'un script qui recherche un mot dans le texte de la page et le surligne, en continuant a cliquer sur le bouton, le mot suivant est surligné,

j'en ai trouvé un qui ne marche pas avec firefox, quelqu'un pourrai m'aider ?


voici le code,

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<script language="JavaScript">
 
var ubSearch=0;
 
function findInPage(str) {
  var txt, i, found;
  if (str=="") return false;
 
  if ((document.layers)||(window.sidebar)) {
    if (!window.find(str)) {
      alert("Fin de page atteinte.\n"+'"'+str+'" trouvé '+ubSearch+" fois.");
      while(window.find(str, false, true)) {ubSearch++;}
    } 
    else
      ubSearch++;
    if (ubSearch == 0)
      alert('"'+str+'" est introuvable');
  }
 
  if (document.all) {
    txt = window.document.body.createTextRange();
    for (i = 0; i <= ubSearch && (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();
      ubSearch++;
    } else {
      if (ubSearch > 0) {
            alert("Fin de page atteinte.\n"+'"'+str+'" trouvé '+ubSearch+" fois.");
 
        ubSearch = 0;
        findInPage(str);
      } else { 
        alert('"'+str+'" est introuvable');
      }
    }
  }
 
  return false;
}
 
</script>
 
 
 
 
 
 
body 
 
 
 
<form name="search" onSubmit="return findInPage(this.motcle.value);">
<font size=3><input name="motcle" type="text" size=30 onFocus="ubSearch=0; if (this.value=='Mot-clé') {this.value=''}" value="Mot-clé"></font>
<input type="submit" value="OK">
</form>
<br><br>
Texte de test
merci,

je souhaiterai rajouter une possibilité de changer la direction de recherche, vers le haut vers le bas...