我用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加到上面的代码里呢?救救我呀!
解决方案 »
- Delphi spcomm 控件
- delphi中怎么获取一个视频文件的原始图形
- 深圳福田)我公司因需要再2名程序员,条件如下:
- 帮帮忙,把这段VB代码改成delphi,小女子先谢谢了,在线等待
- 连接sql server 的问题
- 用什麼函數能取出Windows 色彩中的亮度?
- 关于Tadoconnection.create(self)的问题
- 回答过我<<客户机同时录入时,怎么解决采购入库单的编号冲突问题?>>的进来接分!!!
- delphi连接ORACLE数据库,DBE中连接通过,在DELPHI中用database连接数据库别名,产生如下错误?
- 各位大虾,小弟想做一个局域网文件传输软件,但不知从何下手,望各路高手指点,给出代码!up有分,不断加分。
- 如果判断中文括号和英文括号?
- 在DELPHI5.0里,怎样用TQuery组件,批量更新服务器上的数据?
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
1、index.htm <frameset rows="161,*" cols="*" framespacing="0" frameborder="NO" border="0">
<frame src="top.htm" name="topFrame" scrolling="NO" noresize >
<frame src="book.htm" name="13">
</frameset>===================2、book.htm :<form action="book.cgi" method="POST" name="allsay" id="allsay">
<p align="center"><font color="#0000FF"><a name="添加留言">添加留言</a>:</font></p>
<p align="center">您的姓名:
<input type="text" name="name" size="50">
<br>
电子邮件:
<input type="text" name="email" size="50">
<br>
标题:
<input type="text" name="saysword" size="50">
<br>
<p align="center">您的留言:<br>
<textarea name="comments" COLS="60" ROWS="5"></textarea>
</p>
<p align="center">
<input type="submit" value="添加留言">
*
<input type="reset">
</p>
</form>===============================比如说我用webbrowser打开index.htm ,然后在给book.htm里的saysword赋值为“hello”,然后再把form给submit一下。现在我可以submit form,代码如下:
webbrowser1.oleobject.document.frames.item('13').Document.forms.item('allsay').submit;可是却不知道怎么给sayword赋值,试了好几种办法都不行给sayword赋值得代码应该怎么写呢?
http://www.bytesandmore.de/rad/cpp/files/TCppWebBrowserExe.zip
把这例子下回去看看