Uses ActiveX, Comobj, MSHTML; Depending on the connection text click Connect-General Connection Procedure Htmlclinkbytext (text:string; Wbr:twebbrowser); var Doc:ihtmldocument2; Len,i:integer; Item:olevariant; All:ihtmlelementcollection;begin doc:=wbr.document as IHTMLDocument2; All:=doc. Get_links; Len:=all.length; For i:=0 to Len-1 do begin Item:=all.item (I,varempty); If POS (Text,item. InnerText) >0 then//judgment connection text contains content begin wbr.navigate (ITEM.HREF); End End;end; When using, to click the link containing the word "contact" htmlclinkbytext (' contact ', WebBrowser1); ----------------------------------------------------------------------------------------------Iframe Inside the connection click Function GetFrame (frameno:integer): Iwebbrowser2;varolecontainer:iolecontainer;enum:ienumunknown;unk: IUnknown; Fetched:plongint;beginwhile webbrowser1.readystate <> readystate_complete doapplication.processmessages;if Assigned (webbrowser1.document) thenbeginfetched: = Nil;olecontainer: = webbrowser1.document as IoleconTainer;olecontainer.enumobjects (Olecontf_embeddings, Enum); Enum.skip (Frameno); Enum.next (1, Unk, fetched); Result: = Unk as Iwebbrowser2;endelseresult: = Nil;end; Procedure Tform1.button4click (sender:tobject); vardoc,frm:ihtmldocument2;iw:iwebbrowser2;i,j,len:integer;all:i Htmlelementcollection;item:olevariant;begindoc:=webbrowser1.document as Ihtmldocument2;for i:=0 to Doc.frames.length-1 Dobeginiw:=getframe (i); Frm:=iw. Document as Ihtmldocument2;all:=frm. Get_links; Len:=all.length; For j:=0 to Len-1 do begin Item:=all.item (J,varempty); LISTBOX1.ITEMS.ADD (item. innertext+ ' ~ ' +item.href); Text and the corresponding connection//according to the above POS to determine the item. InnerText contains the content you want to click//And then WebBrowser1.Navigate (ITEM.HREF); ...................... end;end;end;
WebBrowser Web page According to the text to determine to click the link without name and ID