先取出对应frame的document,再取想要的元素,给你我写的函数,新人是应该带着进门的……
//框架获取 function GetDocument(Document:IHTMLDocument2;Index:integer):IHTMLDocument2;//框架获取 var frame_dispatch:IDispatch; framed:IHTMLWindow2; ole_index:OleVariant; begin ole_index:=Index; frame_dispatch:=Document.Frames.ITem(ole_index); if frame_dispatch <> nil then begin framed:=frame_dispatch as IHTMLWindow2; result:=framed.Document as IHTMLDocument2; end else begin result:=nil; end; end;
//点击指定位置或名称的链接,或者给指定的名称或序号的元素赋值 procedure GetItem(Document:IHTMLDocument2;Index:String;IsClick:Boolean;State:integer;Value:string); var IDoc1: IHTMLDocument2; ielc: IHTMLElementCollection; ihtml:IHTMLElement; input:IHTMLInputElement; TextArea:IHTMLTextAreaElement; i:integer; begin Document.QueryInterface(IHTMLDocument2,iDoc1); ielc:=idoc1.Get_all; if(trystrtoint(Index,i))then begin if(IsClick)then begin ihtml:=ielc.item(strtoint(Index),0) as IHTMLElement; ihtml.click; end else begin case State of 0 : begin input:=ielc.item(strtoint(Index),0) as IHTMLInputElement; input.value:=Value; end; 1 : begin TextArea:=ielc.item(strtoint(Index),0) as IHTMLTextAreaElement; TextArea.value:=Value; end; end; end; end else begin if(IsClick)then begin ihtml:=ielc.item(Index,0) as IHTMLElement; ihtml.click; end else begin case State of 0 : begin input:=ielc.item(Index,0) as IHTMLInputElement; input.value:=Value; end; 1 : begin TextArea:=ielc.item(Index,0) as IHTMLTextAreaElement; TextArea.value:=Value; end; end; end; end; end;
这是我百度的技术博客,不懂可以去上边看,或者问……
|