Bonsoir,
à force de chercher j'ai fini par réussir à mettre en surbrillance un mot
contenu dans un iframe depuis un input.
j'aimerai pouvoir faire la même démarche avec successivement chacun des mots placés dans un textarea, mais la j'ai des soucis, si vous avez une idée merci d'avance .
le fichier de base :
<html><head>
<script type="text/javascript" language="JavaScript">
var IE = (document.all); // Détection du navigateur
var n =0;
var a_n = 0;
var doc, a_i, a_trouve;
function TrouveDansPage(chaine) {
if (chaine == ""){return false;}
while(chaine!='' && n<100)
{
if (IE) {
doc = a_win.document.body.createTextRange();
for (a_i = 0; a_i <= a_n && (a_trouve = doc.findText(chaine)) != false; a_i++)
doc.moveStart("character", 1);n++;}
if (a_trouve) {
doc.moveStart("character", -1);
doc.findText(chaine);
doc.execCommand('backcolor','false','orange');a_n++;
}
else {
if (a_n > 0) {
a_n = 0;
TrouveDansPage(chaine);}}}}
</script>
<body onLoad="a_win = window.frames['maFrame'];">
<input type=button value='Retour_liste_résultats'
onClick="TrouveDansPage(document.getElementById('termes').value);"><br>
<iframe name="maFrame" src="doc.htm" width=200px height=200px ></iframe>
<input type='text' name='termes' id='termes' style=visibility:visible value = "mot">
<input type=text id=r0 style=visibility:visible value="test">
<textarea id=eclate style=visibility:visible>mot test etc</textarea>
</center>
</body>
le fichier d iframe : doc.htm
<html>
<head>
</head>
<body bgcolor="#FFFFFF" text="#000000" >
TEST D ECRIT voir des mots
</body>
</html>
[:D][:)]