Mega Code Archive

 
Categories / Delphi / Files
 

How to load a string into the WebBrowser without navigating to a file

Title: How to load a string into the WebBrowser without navigating to a file ? Question: How to load the IE web control with HTML by code ? Answer: Load the string into a Variant array and then write to the Document: uses MSHTML, // IHTMLDocument2 ACTIVEX; // PSafeArray ... var v: Variant; HTMLDocument: IHTMLDocument2; begin HTMLDocument := WebBrowser1.Document as IHTMLDocument2; v := VarArrayCreate([0, 0], varVariant); v[0] := HTMLString; // Here's your HTML string HTMLDocument.Write(PSafeArray(TVarData(v).VArray)); HTMLDocument.Close; ... end; More useful hints concerning the web on: http://members.home.com/hfournier/ This tip provided by Ron Loewy