可能上个问题说的不太清楚或是分值太低,致使无人问津,现在将代码简化,再次发表。
问题是:ShowMessage 为何总是0。下面是我的代码:procedure TForm1.FormCreate(Sender: TObject);
var
   IDoc : IHTMLDocument2;
   strHTML : String;
   v : Variant;
begin   IDoc := CreateComObject(Class_HTMLDOcument) as IHTMLDocument2;
   try
     IDoc.designMode := 'on';
     while IDoc.readyState <> 'complete' do
       Application.ProcessMessages;
     v:= VarArrayCreate([0,0],VarVariant);     strHTML := IdHttp.Get('http://www.sina.com.cn/');
     v[0]:= strHTML;
     IDoc.write(PSafeArray(System.TVarData(v).VArray)) ;
     IDoc.designMode:='off';
     while IDoc.readyState <> 'complete' do
       Application.ProcessMessages;     ShowMessage(IntToStr(HtmlDoc.Body.getAttribute('offsetHeight', 0)));
   finally
     IDoc := nil;
   end;
end;