我在数据库里面保存的内容是HTML格式的数据,但是在WebBrowser我每次都要另存为HTML文件用Navigate才能链接显示,如何让WebBrowser直接取出数据库里面的数据,直接显示内容?    谢谢!

解决方案 »

  1.   

    function LoadFromStream(const AStream: TStream): HRESULT;
    begin
      AStream.seek(0, 0);
      Result := (Webbrowser1.Document as
    IPersistStreamInit).Load(TStreamadapter.Create(AStream));
    end;procedure LoadFromStrings(const AStrings: TStrings);
    var
      M: TMemoryStream;
    begin
      M := TMemoryStream.Create;
      try
        AStrings.SaveToStream(M);
        Result := LoadFromStream(M);
      finally
        M.free;
      end;
    end;Try this way。
      

  2.   

    uses activex;initialization
      OleInitialize(nil);finalization
      OleUninitialize;取数据的话是:
    function GetWebBrowserText(IE: TWebBrowser): string;
    var
      Doc: IHtmlDocument2;
      Body: IHtmlElement;
    begin
      try
      Result := '';
      Doc := IE.Document as IHtmlDocument2;
      if Doc = nil then Exit;
      Body := Doc.Body;  if Body = nil then Exit;
      Result := Body.innerText;
      except end;
    end;写入数据的话是:(IE.Document as IHtmlDocument2).body.innertext:= '你要显示得html';操作之前一定要 navigate('about:blank'),初始化网页,
      

  3.   

    Doc: IHtmlDocument2;
    Body: IHtmlElement;出错,要引用哪个系统单元文件?
      

  4.   

    uses mshtml
    procedure TForm1.Button1Click(Sender: TObject);
        var
          sHTML: string;
        begin
          sHTML :=’〈P〉This is some Html text.〈/P〉’;
          WebBrowser1.OleObject.Document.body.innerHTML :=sHTML;
        end;