unit Unit1;interfaceuses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, OleCtrls, SHDocVw, EmbeddedWB, StdCtrls, ActiveX, MShtml;type
  TForm1 = class(TForm)
    Button1: TButton;
    WebBrowser: TWebBrowser;
    procedure Button1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure WebBrowserDocumentComplete(Sender: TObject; const pDisp: IDispatch;
      var URL: OleVariant);
  private
    { Private declarations }
    ms : TMemoryStream;
  public
    { Public declarations }
  end;var
  Form1: TForm1;implementation{$R *.dfm}
const fpath = 'C:\Documents and Settings\Wxz\桌面\';
procedure TForm1.Button1Click(Sender: TObject);
  var s : string;
begin
  ms.Clear;       s := fpath + 'main.HTM';
  ms.LoadFromFile(s);   ms.Seek(0,0);
  if WebBrowser.Document <> nil then
    (WebBrowser.Document as IPersistStreamInit).Load(TStreamAdapter.Create(ms));
end;procedure TForm1.FormCreate(Sender: TObject);
begin
  ms := TMemoryStream.Create;
  WebBrowser.Navigate('about:blank');
end;procedure TForm1.WebBrowserDocumentComplete(Sender: TObject;
  const pDisp: IDispatch; var URL: OleVariant);
var   s : string;
begin
  s := URL;
  if not ansiSameText(s,'about:blank') then begin
    Delete(s,1,Length('about:blank'));
    s := fpath + s;  ms.Clear;
    ms.LoadFromFile(s); ms.Seek(0,0);
    if pDisp <> nil then begin
      if (pDisp as IWebBrowser2).Document <> nil then
        (((pDisp as IWebBrowser2).Document) as IPersistStreamInit).Load(TStreamAdapter.Create(ms));
    end;
  end;
end;end.main.htm 中为 <html><head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title></title>
</head><frameset cols="200,*">
  <frame name="contents" target="main" src="cont.html">
  <frame name="main" src="face.htm" target="main" scrolling="auto">
  <noframes>
  <body>
  <p>This page uses frames, but your browser doesn't support them.</p>
  </body>
  </noframes>
</frameset>
</html>

解决方案 »

  1.   

    procedure  TForm1.WebBrowserDocumentComplete(Sender:  TObject;  
       const  pDisp:  IDispatch;  var  URL:  OleVariant);  
    是face.htm 和 cont.html从TMemoryStream中写入到 frame 中去能写入,但WebBrowser不显示两个frame的内容
      

  2.   

    Webbrowser1.Navigate('C:\Documents and Settings\Wxz\桌面\main.HTM');不知楼主为什么不直接指向HTM文件?
      

  3.   

    NI想要什麼味道呀?把一個很簡単的問題写出一堆馬子、就有味道了?NI自己慢慢品味吧!還有、貼子発錯地方了!