Mega Code Archive

 
Categories / Delphi / LAN Web TCP
 

Append HTML Text to a TWebbrowser Document

Title: Append HTML Text to a TWebbrowser Document Question: The following example shows how to append html text to the end of a TWebbrowser Document. Answer: The IHTMLTxtRange interface is used to retrieve and modify text in an element, locate specific strings in the text, and carry out commands that affect the appearance of the text.It enables you to access the TextRange object in an HTML element. uses MSHTML; procedure TForm1.Button1Click(Sender: TObject); var Range: IHTMLTxtRange; begin // createTextRange is used to to examine and modify the text within an object. Range := ((WebBrowser1.Document as IHTMLDocument2).body as IHTMLBodyElement).createTextRange; // Moves the insertion point to the beginning or end of the current range. Range.collapse(False); // Paste html Range.pasteHTML('Hello!'); end; // Navigate to a webpage procedure TForm1.Button2Click(Sender: TObject); begin Webbrowser1.Navigate('www.google.com'); end;