可不可以直接修改网页的源文件并让IE体现出来?

解决方案 »

  1.   

    //直接在WebBrowser中显示字符串
    procedure ShowInWebBrowser(WebB:TWebBrowser;Str:String);
    var
     v: Variant;
     HTMLDocument: IHTMLDocument2;
    begin
     HTMLDocument := WebB.Document as IHTMLDocument2;
     if (assigned(HtmlDocument)) then  begin
       v := VarArrayCreate([0, 0], varVariant);
       v[0] := str; //that is to be shown
       HTMLDocument.Write(PSafeArray(TVarData(v).VArray));
       HTMLDocument.Close;
     end;
    end;
    //直接修改TWebBrowser显示内容
    procedure TForm1.Button1Click(Sender: TObject); 
    begin 
      Webbrowser1.Navigate('about:blank');
    end; procedure TForm1.Button2Click(Sender: TObject); 
    var 
      V: OleVariant; 
    begin 
      V := WebBrowser1.Document;
      s := '<html><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312"></head><body>'+
           '<style type="text/css">' +
           'body {font-family: "宋体", "Times New Roman"; font-size: 12px;margin-left: 0px;margin-top: 0px;margin-right: 0px;margin-bottom: 0px;}' +
           '</style><b>Welcome!</b></body>';
      V.Script.Document.Body.InnerHTML := s;
    end; 
      

  2.   

    在MSDN上有资料可以查找。
    blender(路路) 的办法难道不是你想要的吗??
      

  3.   

    http://www.euromind.com/iedelphi/ie5tools/ieautomate.htm