J'ai utilisé ce code pour chercher un mot dans le WebBrowser :
Mais :
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 procedure TForm1.SearchAndHighlightText(aText: string); var tr: IHTMLTxtRange; //TextRange Object begin if not WebBrowser1.Busy then begin tr := ((WebBrowser1.Document as IHTMLDocument2).body as IHTMLBodyElement).createTextRange; //Get a body with IHTMLDocument2 Interface and then a TextRang obj. with IHTMLBodyElement Intf. while tr.findText(aText, 1, 0) do //while we have result begin tr.pasteHTML('<span style="background-color: Lime; font-weight: bolder;">' + tr.htmlText + '</span>'); //Set the highlight, now background color will be Lime tr.scrollIntoView(True); //When IE find a match, we ask to scroll the window... you dont need this... end; end; end;
j'ai un ListBox contenant les pages à naviguer :
Exemple :
c:\pages\page1.htm
c:\pages\page2.htm
c:\pages\page3.html
...
Donc ce que je veux que le WebBrowser puisse naviguer toutes ces pages ( trouvant dans le ListBox ) une par une et faire la recherche ( Find ) du Mot , s'il le trouve il affiche le nom de page contenant le mot .
Ce que j'ai fait :
mais à l'execution le Webbrowser1 navigue seulement la 1ere et dernière page , et il ignore les autres pages.procedure TForm1.timer1Timer(Sender: TObject);
var
i:integer;
begin
For i:=0 to listbox1.items.cout-1 do
begin
WebBrowser1.Navigate(ListBox1.Items.Strings[i]);
SearchAndHighlightText(Edit1.text);
end;
end;
Merçi
Partager