hallo dizzy
dachte ich zuerst auch nur wenn du dir mal
folgendes beispiel ansiehst wirst du sehen, dass dort IHTMLElementCollection verwendet wird:
Delphi-Quellcode:
procedure TfrmMain.mViewSourceClick(Sender: TObject);
{show page source}
{document.Body.ParentElement.OuterHtml causes AV}
{look for <html> tag and get the InnerHtml from it - Nick Bradbury}
{source that is actually shown in browser including any created by javascript}
var
sPage :
string;
hDoc: IHTMLDocument2;
hElm : IHTMLElement;
hCol : IHTMLElementCollection;
i, nLen : integer;
frmSource: TfrmSource;
begin
{get page source}
if not(mzGecko.Busy)
then begin
try
hDoc := mzGecko.Document
as IHTMLDocument2;
{first get body, in case looking for <html> fails}
sPage := hDoc.Body.OuterHtml;
{get collection of all elements, then look for <html>}
hCol := hDoc.All;
if (Assigned(hCol))
then begin
nLen := hCol.length;
for i := 0
to nLen - 1
do begin
hElm := IHTMLElement(hCol.Item(i, varEmpty));
if SameText(hElm.TagName, '
html')
then sPage := hElm.InnerHtml;
{found <html>}
end;
{for i..}
end;
{if Assigned(hCol)..}
{show in frmSource (frees itself when closed)}
frmSource := TfrmSource.Create(self);
frmSource.Caption := frmSource.Caption + cmbxAddress.Text;
frmSource.mmSource.Lines.Add(sPage);
frmSource.Show;
except
{handle exceptions}
on E :
Exception do begin
MessageDlg('
ERROR: Unable to View Source.' + #13 + E.ClassName
+ '
: ' + E.
Message + '
.', mtError, [mbOk], 0);
end;
{on Exception..}
end;
{try..except..}
end;
{if not(mzGecko.Busy)..}
end;
{procedure TfrmMain.mViewSourceClick}
[EDIT]
hat das was mit mit meinem problem zu tun?