遇到了问题。
代码如下:
procedure TForm1.Button1Click(Sender: TObject);
{打开HTML代码}
begin
WebBrowser1.Navigate('C:\2.htm');
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
{HTML提交}
WebBrowser1.OleObject.Document.form1.submit;
{这里一提交就出现错误,以前我这样提交都没问题的不知道现在怎么了?}
end;
HTML代码:
<form name="form1" method="post" action="http://www.163.com">
<input type="text" name="textfield">
<input type="submit" name="Submit" value="Submit">
</form>
点击BOUTTON2的时候出现错误。
错误是:
Project Project1.exe raised exception class EOleSysError With message '找不到成员。'.
Process stopped. Use Step or Run to continue.
希望大侠们帮帮忙!!
9 个解决方案
#1
帮顶一下。
顶的人也有分拿!
顶的人也有分拿!
#2
我业碰到这个问题,呵呵,哪位高手解决一下啊
#3
up
#4
没做过这类,严重帮你顶!
#5
代码就一点啊。
帮帮忙啊!!!
帮帮忙啊!!!
#6
建议你用这段代码试试:
uses msHtml
procedure TForm1.Button1Click(Sender: TObject);
var
Doc: IHtmlDocument2;
Form: IHTMLFormElement;
begin
Doc := WebBrowser1.Document as IHtmlDocument2;
Form := Doc.forms.item('Form1', 0) as IHTMLFormElement;
(Form.item('Submit', 0) as IHtmlElement).click;
end;
#7
我试过,是可以用的。
#8
你可以看看这篇文章
http://www.csdn.net/develop/Read_Article.asp?Id=22030
http://www.csdn.net/develop/Read_Article.asp?Id=22030
#9
press a button in a TWebbrowser when there are multiple buttons in the same form?
// If there is only one button, you can do something like:
WebBrowser1.OleObject.Document.forms.item(0).elements.item(0).click;
// This will do a click on the first element of the first <FORM>, where an
// element is either <INPUT>, <SELECT> or <TEXTAREA>.
// If there is more than one button, you can do something like:
procedure TForm1.Button1Click(Sender: TObject);
var
ovElements: OleVariant;
i: Integer;
begin
ovElements := WebBrowser1.OleObject.Document.forms.item(0).elements;
for i := 0 to (ovElements.Length - 1) do
if (ovElements.item(i).tagName = 'INPUT') and
(ovElements.item(i).type = 'SUBMIT') and
(ovElements.item(i).Value = 'Recent Charges') then
ovElements.item(i).Click;
end;
// If there is only one button, you can do something like:
WebBrowser1.OleObject.Document.forms.item(0).elements.item(0).click;
// This will do a click on the first element of the first <FORM>, where an
// element is either <INPUT>, <SELECT> or <TEXTAREA>.
// If there is more than one button, you can do something like:
procedure TForm1.Button1Click(Sender: TObject);
var
ovElements: OleVariant;
i: Integer;
begin
ovElements := WebBrowser1.OleObject.Document.forms.item(0).elements;
for i := 0 to (ovElements.Length - 1) do
if (ovElements.item(i).tagName = 'INPUT') and
(ovElements.item(i).type = 'SUBMIT') and
(ovElements.item(i).Value = 'Recent Charges') then
ovElements.item(i).Click;
end;
#1
帮顶一下。
顶的人也有分拿!
顶的人也有分拿!
#2
我业碰到这个问题,呵呵,哪位高手解决一下啊
#3
up
#4
没做过这类,严重帮你顶!
#5
代码就一点啊。
帮帮忙啊!!!
帮帮忙啊!!!
#6
建议你用这段代码试试:
uses msHtml
procedure TForm1.Button1Click(Sender: TObject);
var
Doc: IHtmlDocument2;
Form: IHTMLFormElement;
begin
Doc := WebBrowser1.Document as IHtmlDocument2;
Form := Doc.forms.item('Form1', 0) as IHTMLFormElement;
(Form.item('Submit', 0) as IHtmlElement).click;
end;
#7
我试过,是可以用的。
#8
你可以看看这篇文章
http://www.csdn.net/develop/Read_Article.asp?Id=22030
http://www.csdn.net/develop/Read_Article.asp?Id=22030
#9
press a button in a TWebbrowser when there are multiple buttons in the same form?
// If there is only one button, you can do something like:
WebBrowser1.OleObject.Document.forms.item(0).elements.item(0).click;
// This will do a click on the first element of the first <FORM>, where an
// element is either <INPUT>, <SELECT> or <TEXTAREA>.
// If there is more than one button, you can do something like:
procedure TForm1.Button1Click(Sender: TObject);
var
ovElements: OleVariant;
i: Integer;
begin
ovElements := WebBrowser1.OleObject.Document.forms.item(0).elements;
for i := 0 to (ovElements.Length - 1) do
if (ovElements.item(i).tagName = 'INPUT') and
(ovElements.item(i).type = 'SUBMIT') and
(ovElements.item(i).Value = 'Recent Charges') then
ovElements.item(i).Click;
end;
// If there is only one button, you can do something like:
WebBrowser1.OleObject.Document.forms.item(0).elements.item(0).click;
// This will do a click on the first element of the first <FORM>, where an
// element is either <INPUT>, <SELECT> or <TEXTAREA>.
// If there is more than one button, you can do something like:
procedure TForm1.Button1Click(Sender: TObject);
var
ovElements: OleVariant;
i: Integer;
begin
ovElements := WebBrowser1.OleObject.Document.forms.item(0).elements;
for i := 0 to (ovElements.Length - 1) do
if (ovElements.item(i).tagName = 'INPUT') and
(ovElements.item(i).type = 'SUBMIT') and
(ovElements.item(i).Value = 'Recent Charges') then
ovElements.item(i).Click;
end;