Here's how to append (add) "static" HML code from a string into a TWebBrowser:
Usage: Simply drop an instance of TWebBrowser component on a form, HTML code gets loaded in the OnCreate event for a form. The Button's click event handler appends a link to About Delphi Programming web site at the bottom of the document
~~~~~~~~~~~~~~~~~~~~~~~~~
uses MSHTML;
procedure AppendToWB(WB: TWebBrowser; const html: widestring) ;
var
Range: IHTMLTxtRange;
begin
Range := ((WB.Document AS IHTMLDocument2).body AS IHTMLBodyElement).createTextRange;
Range.Collapse(False) ;
Range.PasteHTML(html) ;
end;
procedure TForm1.FormCreate(Sender: TObject) ;
begin
WebBrowser1.Navigate('http://aspxDelphi.net') ;
end;
procedure TForm1.Button1Click(Sender: TObject) ;
var
s: string;
begin
s:= '<a href="http://delphi.about.com">go to About Delphi Programming</a>';
AppendToWB(WebBrowser1,s) ;
end;
~~~~~~~~~~~~~~~~~~~~~~~~~
Delphi tips navigator:
» Sending email messages in .Net
« Simulating keystrokes from code

