procedure TForm1.Button1Click(Sender: TObject);
begin
  EmbeddedWB1.Navigate('http://www.educationnews.org/commentaries/76622.html'));
end;procedure TForm1.EmbeddedWB1NavigateComplete2(ASender: TObject;
  const pDisp: IDispatch; var URL: OleVariant);
begin
  if glpDisp = nil then glpDisp := pDisp;
end;procedure TForm1.EmbeddedWB1DocumentComplete(ASender: TObject;
  const pDisp: IDispatch; var URL: OleVariant);
begin
  if (glpDisp <> nil) and (glpDisp = pDisp) then
  begin
    glpDisp := nil;
    ShowMessage('OK');
  end;
end;
大多数网页用此方法来判断加载完毕都没问题,但是有些网页,比如我代码里的这个,如果单击后等待,就会发现弹出了窗口,但页面显示空白,我右键显示源代码,发现源代码都下载完毕了,这是怎么回事呢?恳请各位大大指教

解决方案 »

  1.   

    get是怎麼寫的?WebBrowser.OleObject.Document.XMLDocument...
      

  2.   

    eg:uses MSHTML, ActiveX,comobj;function GetHtml(const WebBrowser:TWebBrowser): string;
    const
    BufSize = $10000;
    var
    Size: Int64;
    Stream: IStream;
    hHTMLText: HGLOBAL;
    psi: IPersistStreamInit;
    begin
    if not Assigned(WebBrowser.Document) then Exit;OleCheck(WebBrowser.Document.QueryInterface(IPersistStreamInit, psi));
    try
        hHTMLText := GlobalAlloc(GPTR, BufSize);
        if 0 = hHTMLText then RaiseLastWin32Error;    OleCheck(CreateStreamOnHGlobal(hHTMLText, True, Stream));
        try
          OleCheck(psi.Save(Stream, False));      Size := StrLen(PChar(hHTMLText));
          SetLength(Result, Size);
          CopyMemory(PChar(Result), Pointer(hHTMLText), Size);
        finally
          Stream := nil;
        end;
    finally
        psi := nil;
    end;
    end;
      

  3.   


    我想您没明白我的问题,我是想要让webbrowser把网页显示出来,而不是要取他的源代码
      

  4.   


    的确是这个问题,请问有没有办法实时修改编码呢?貌似webbrowser中无法直接修改啊