webbrowser and Find
I use this code to find and highlight a word in the WebBrowser :
Delphi-Quellcode:
I fill ListBox1 :
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;
Delphi-Quellcode:
So what i want is that the webbrowser navigates all the pages in the ListBox1
Var
i:Integer; begin if Opendialog1.execute then For i:=0 to Opendialog1.files.cout-1 do Listbox1.items.add(Opendialog1.Files[i]); end; what i do :
Delphi-Quellcode:
But when i execute it the webbrowser navigates only the :
Var
i:integer; begin For i:=0 to listbox1.items.cout-1 do begin {Let's suppose listbox1 contains : Page1 page2 page3 } WebBrowser1.Navigate(ListBox1.Items.Strings[i]); SearchAndHighlightText(Edit1.text); // I use edit1 to type the searched keyword 1st and the Last page. |
Re: webbrowser and Find
Hi,
you only should start to search and highlight after the document is loaded and rendered. You can detect this state when you provide code for the event OnDocumentComplete(). There is absolutely no sense in looping through a list of urls without some means of control for the user. Regards |
Re: webbrowser and Find
Thank you marabu
is there any means i cann search these Pages Without loading them into this WebBrowser, or can i load them in Memory and search many thanks |
Re: webbrowser and Find
Of course, you can fetch the markup without rendering it. Use TIdHTTP.Get() which is employed by UrlDownload() - or have a look at UrlMon.UrlDownloadToFile().
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 11:43 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz