procedure TForm1.btnClickUrlClick(Sender: TObject);
var
J:integer;
spDisp: IDispatch;
IDoc1: IHTMLDocument2;
ielc: IHTMLElementCollection ;
ihtml:IHTMLElement;
iane:IHTMLAnchorElement;
begin
WebNav.Document.QueryInterface(IHTMLDocument2,iDoc1);
ielc:=idoc1.Get_all;
for J:=0 to ielc.length-1 do
begin
Application.ProcessMessages;
spDisp := ielc.item(J, 0);
if SUCCEEDED(spDisp.QueryInterface(IHTMLAnchorElement ,iane))then
begin
if iane.href='http://www.nq51.com/' then //这里我在网页里的url是http://www.nq51.com调用的时候自动加上了'/'需要注意一下
begin
ihtml:=ielc.item(J,0) as IHTMLElement;
ihtml.click;
end;
end;
end;
end;
比格高
逼格更高