uses
ActiveX;
//从STRING加载到WEB
procedure WB_LoadHTML(WebBrowser: TWebBrowser; HTMLCode: string);
var
sl: TStringList;
ms: TMemoryStream;
begin
WebBrowser.Navigate('about:blank');
while WebBrowser.ReadyState < READYSTATE_INTERACTIVE do
Application.ProcessMessages;
if Assigned(WebBrowser.Document) then
begin
sl := TStringList.Create;
try
ms := TMemoryStream.Create;
try
sl.Text := HTMLCode;
sl.SaveToStream(ms);
ms.Seek(0, 0);
(WebBrowser.Document as IPersistStreamInit).Load(TStreamAdapter.Create(ms));
finally
ms.Free;
end;
finally
sl.Free;
end;
end;
end;
//从STREAM加载到WEB
function Loadfromstream(AStream:TStream):hresult;
begin
with browser1 do
begin
if not Assigned(Document) then
begin
navigate2('about:blank',0,0,0,0);
while readystate <> READYSTATE_COMPLETE do Forms.Application.ProcessMessages;
end;
AStream.seek(0, 0);
Result := (Document as IPersistStreamInit).Load(TStreamadapter.Create(AStream));
end;
end;