在一个Twebbrowse中打开一个网页,取得它的ihtmldocument2接口后,进行一系列的操作,页面内容已经变成另外一个网页的内容了,但再次取ihtmldocument2的接口时。不是新的网页的内容的接口,还是以前老的接口。这是怎么回事???各位大虾帮忙啊!!!!downcomplete := false;
LNK.click;
repeat
    application.preessmessage;
until downcomplete;
doc := wb.document as ihtmldocument2;
memo1.Lines.Add(doc.body.outerText);

解决方案 »

  1.   

    调用 navigate 方法后是立即返回的,这时Doc:=webb.document as ihtmldocument2 返回 nil ,必须等待下载完毕才能使用 Doc:=webb.document as ihtmldocument2
    加个 
     while WebB.Busy do
        Application.ProcessMessages ;
    试试
      

  2.   

    repeat
              Application.ProcessMessages ;
            until(not WebB.Busy); 
            doc:=webbrowser1.document as ihtmldocument2;  
            if doc<>nil then       //链接出错则doc=nil
             all:=webbrowser1.all;
            memo1.Lines.Add(doc.body.outerText);