W
weitu
Unregistered / Unconfirmed
GUEST, unregistred user!
我使用IdHttp控件取回某个URL的IHTMLDocument2后赋给HtmlDoc,但是在使用HtmlDoc.Body.getAttribute('offsetHeight', 0) 值始终为 0,而HtmlDoc.title等确非常正确,不知何故,寻求大师指点。下面是我取IHTMLDocument2的函数:
function TfrmSave.GetHTMLDoc(const AURL: String) : IHTMLDocument2;
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(AURL);
v[0]:= strHTML;
IDoc.write(PSafeArray(System.TVarData(v).VArray)) ;
IDoc.designMode:='off';
while IDoc.readyState <> 'complete' do
Application.ProcessMessages;
Result := IDoc;
finally
IDoc := nil;
end;
end;
function TfrmSave.GetHTMLDoc(const AURL: String) : IHTMLDocument2;
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(AURL);
v[0]:= strHTML;
IDoc.write(PSafeArray(System.TVarData(v).VArray)) ;
IDoc.designMode:='off';
while IDoc.readyState <> 'complete' do
Application.ProcessMessages;
Result := IDoc;
finally
IDoc := nil;
end;
end;