下面是一个例子:<br>var<br> Document: IHTMLDocument2;<br> Idx: OleVariant;<br> Window: OleVariant;<br> i: Integer;<br>begin<br> Document:=WebBrowser1.Document as IHTMLDocument2;<br> Idx:=0;<br> Window:=Document.frames.item(Idx);<br> for i:=0 to Window.document.all.length-1 do<br> begin<br> //如果预先知道按钮的名字,那么可以直接这样写Window.document.s1.click;<br> if SameText(Window.document.all.item(i).tagName,'input') then<br> if SameText(Window.document.all.item(i).value,'s1') then<br> begin<br> Window.document.all.item(i).click;<br> break;<br> end;<br> end;<br><br> Document:=WebBrowser1.Document as IHTMLDocument2;<br> Idx:=1;<br> Window:=Document.frames.item(Idx);<br> for i:=0 to Window.document.all.length-1 do<br> begin<br> if SameText(Window.document.all.item(i).tagName,'input') then<br> if SameText(Window.document.all.item(i).value,'s2') then<br> begin<br> Window.document.all.item(i).click;<br> break;<br> end;<br> end;<br> 。。。<br>end;<br>