调用下面的函数实现load....
procedure Navigate(html: TStrings; var browser: TWebbrowser);
var
Document: OleVariant;
InStream: TStream;
Persist: IPersistStreamInit; // Declared in ActiveX
begin
if (html <> nil) and (html.count > 0) then
begin
InStream := TStringStream.Create(html.text);
try
if Browser.Document = nil then
browser.Navigate('about:blank');
Persist := (Browser.Document as IPersistStreamInit);
Persist.Load(TStreamAdapter.Create(InStream));
finally
InStream.Free;
end;
end
else
browser.Navigate('about:blank');
end;
调用思路:
list:TStrings;
list.Add('<body>');
.......//写入hmtl
list.Add('</body>');
...
Navigate(list,webbrowser1);