uses ActiveX,MSHTML //加上两个单元!procedure ShowInWebBrowser(WebB:TWebBrowser;Str:String);varv: Variant;HTMLDocument: IHTMLDocument2;beginHTMLDocument := WebB.Document as IHTMLDocument2;if (assigned(HtmlDocument)) then beginv := VarArrayCreate([0, 0], varVariant);v[0] := str; //that is to be shownHTMLDocument.Write(PSafeArray(TVarData(v).VArray));HTMLDocument.Close;end;end;//调用str= '输出内容 ';ShowInWebBrowser(WebBrowser1, '输出内容 ');//可以为任意内容,包括HTML代码!还有种方法,不如上面的灵活,但很简单实用!str= '输出内容 ';webbrowser1.Navigate( 'about: '+str);
联系客服