首页  编辑  

直接写HTML字符串到WebBrowser

Tags: /超级猛料/OS.操作系统/IE.扩展/TWebBrowser/页面内容/   Date Created:

直接写入HTML字符串到WebBrowser控件中

uses mshtml , ActiveX , ComObj ;

procedure TForm1 . Button1Click ( Sender : TObject );

var

 v : Variant ;

 HTMLDocument : IHTMLDocument2 ;

begin

 WebBrowser1 . Navigate ( 'about:blank' );

 HTMLDocument := WebBrowser1 . Document as IHTMLDocument2 ;

 v := VarArrayCreate ([ 0 , 0 ], varVariant );

 v [ 0 ] := '<HTML><h1>Test</h1><br>aaaaaa</html>' ; // Here's your HTML string

 HTMLDocument . Write ( PSafeArray ( TVarData ( v ). VArray ));

 HTMLDocument . Close ;

end ;