我用WebBrowser控制网页中的对象,像你说的两种方法:
有两种写法:
1:
Uses MSHTML //IHTMLDocument2,IHTMLInputElement,IHTMLFormElement等在其中定义,必须加上该单元!
var
Doc:IHTMLDocument2;
Input:IHTMLInputElement;
Form:IHTMLFormElement;
begin
Doc:=Webbrowser1.Document as IHTMLDocument2;
Input:= Doc.all.item('name',0) as IHTMLInputElement;
//或者Input:= IHTMLDocument2(Webbrowser1.Document).all.item('name',0) as IHTMLInputElement;
Input.value:='Test';
Input:= Doc.all.item('pass',0) as IHTMLInputElement;
//或者Input:= IHTMLDocument2(Webbrowser1.Document).all.item('name',0) as IHTMLInputElement;
Input.value:='123456';
Form:= Doc.all.item('alogon',0) as IHTMLFormElement;
Form.submit;
end;
2:
With WebBrowser1.OleObject.document do
begin
all.item('name').value:='Test';
all.item('pass').value:='123456;
forms.item('alogon').submit;
end;
可是在没有Frame的情况下没问题(再次表示感谢!)。
可拿到有Frame的页面里就不行了,我应该怎么改上面的那些代码呢?
我要控制的对象在Frame:<frame src="output.htm" name="send">里。
也就是说要控制的对象在“output.htm”里。
我该怎么把Frame加到上面的代码里呢?
救救我呀!
有两种写法:
1:
Uses MSHTML //IHTMLDocument2,IHTMLInputElement,IHTMLFormElement等在其中定义,必须加上该单元!
var
Doc:IHTMLDocument2;
Input:IHTMLInputElement;
Form:IHTMLFormElement;
begin
Doc:=Webbrowser1.Document as IHTMLDocument2;
Input:= Doc.all.item('name',0) as IHTMLInputElement;
//或者Input:= IHTMLDocument2(Webbrowser1.Document).all.item('name',0) as IHTMLInputElement;
Input.value:='Test';
Input:= Doc.all.item('pass',0) as IHTMLInputElement;
//或者Input:= IHTMLDocument2(Webbrowser1.Document).all.item('name',0) as IHTMLInputElement;
Input.value:='123456';
Form:= Doc.all.item('alogon',0) as IHTMLFormElement;
Form.submit;
end;
2:
With WebBrowser1.OleObject.document do
begin
all.item('name').value:='Test';
all.item('pass').value:='123456;
forms.item('alogon').submit;
end;
可是在没有Frame的情况下没问题(再次表示感谢!)。
可拿到有Frame的页面里就不行了,我应该怎么改上面的那些代码呢?
我要控制的对象在Frame:<frame src="output.htm" name="send">里。
也就是说要控制的对象在“output.htm”里。
我该怎么把Frame加到上面的代码里呢?
救救我呀!
解决方案 »
- 原函数用void声明,在delphi应该怎样写?
- 给配置文件ini加个密!如何做到啊?抢分题!
- 救命阿,我的软件做好了,录了视频演示,可是现在所有的都不能播放了。
- 关于条形码制作 请高手帮帮忙!!!!!!1
- 从TInterfacedObject继承来的类........
- 哪位给我一个好一点的教育网(出国)的代理?
- 急!为什么RichEdit中的CFM_HIDDEN(隐藏)没有效果,象其他的CFM_STRIKEOUT(删除线)却有效果,我用的是RichEdit3.0版本。
- 急!我要安裝在大富翁下载的D6,急需要SN, 請哪位大俠告訴我,thank you very much
- 各位有没有碰到ado连接的数据库表提示你定义了太多的字段!!!!
- 请教高手一个问题有关dbgrid记录数的问题和一个dbgrid对象备份的问题。
- 又sos!
- delphi中的文件操作问题!100分
doc:IHTMLDocument2;
win:IHTMLWindow2;
framesCollection:IHTMLFramesCollection2;
input:IHTMLInputElement;
vFrame,ret:OleVariant;
begin
doc:=WebBrowser1.Document as IHTMLDocument2;
framesCollection:=(doc.get_frames as IHTMLFramesCollection2);
TVariantArg(vFrame).vt:=VT_UINT;
TVariantArg(vFrame).iVal:=0;
ret:=framesCollection.item(vFrame);
TVariantArg(ret).pdispVal.QueryInterface(IID_IHTMLWindow2,win);
input:=((win.document as IHTMLDocument2).all.item('name',0) as IHTMLInputElement);
input.value:='Test';
end;
http://www.bytesandmore.de/rad/cpp/files/TCppWebBrowserExe.zip