查找并且高亮文本

  • 主题发起人 主题发起人 import
  • 开始时间 开始时间
I

import

Unregistered / Unconfirmed
GUEST, unregistred user!
find and highlight text in TWebBrowser? {....}
private
procedure SearchAndHighlightText(aText: string);
 
{....}
procedure TForm1.SearchAndHighlightText(aText: string);
var
i: Integer;
begin
for i := 0 to WebBrowser1.OleObject.Document.All.Length - 1 do
begin
if Pos(aText, WebBrowser1.OleObject.Document.All.Item(i).InnerText) <> 0 then
begin
WebBrowser1.OleObject.Document.All.Item(i).Style.Color := '#FFFF00';
WebBrowser1.OleObject.Document.All.Item(i).ScrollIntoView(True);
end;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
SearchAndHighlightText('some text...');
end;
 
后退
顶部