C
cgfhz
Unregistered / Unconfirmed
GUEST, unregistred user!
本人在TForm上用TWebBrowser写了个自动提交程序,但OnClick无效。
高分赐教~~~[]
代码如下:
procedure TfrmHtmlInfo.ExtractLinks(WebBrowser: TWebBrowser);
var
pDoc: IHTMLDocument2;
HtmlForms: IHTMLElementCollection;
HtmlForm: IHTMLFormElement;
FormName: string;
i, ItemIndex, ItemName: integer;
InputElement: IHTMLInputElement;
begin
try
if SUCCEEDED(WebBrowser.Document.QueryInterface(IHTMLDocument2, pDoc)) then
begin
if pDoc.title = '我的标题' then
//标题名
begin
HtmlForms := pDoc.forms;
if HtmlForms.length <= 0 then
exit;
HtmlForm := (HtmlForms.item(0, 0) as IHTMLFormElement);
FormName := trim(HtmlForm.Get_name);
if FormName = 'mei' then
//名称
begin
for I := 0 to HtmlForm.Length - 1do
begin
ItemIndex := 0;
ItemName := I;
if Supports(HtmlForm.item(ItemName, ItemIndex), IHTMLInputElement, InputElement) then
begin
if (InputElement.type_ = 'submit') and
(InputElement.value = '文本文件') then
begin
(InputElement as IHtmlElement).OnClick := OleVariant(Self as IDispatch);
break;
end;
end;
end;
end;
end;
end;
except
//
end;
end;
高分赐教~~~[]
代码如下:
procedure TfrmHtmlInfo.ExtractLinks(WebBrowser: TWebBrowser);
var
pDoc: IHTMLDocument2;
HtmlForms: IHTMLElementCollection;
HtmlForm: IHTMLFormElement;
FormName: string;
i, ItemIndex, ItemName: integer;
InputElement: IHTMLInputElement;
begin
try
if SUCCEEDED(WebBrowser.Document.QueryInterface(IHTMLDocument2, pDoc)) then
begin
if pDoc.title = '我的标题' then
//标题名
begin
HtmlForms := pDoc.forms;
if HtmlForms.length <= 0 then
exit;
HtmlForm := (HtmlForms.item(0, 0) as IHTMLFormElement);
FormName := trim(HtmlForm.Get_name);
if FormName = 'mei' then
//名称
begin
for I := 0 to HtmlForm.Length - 1do
begin
ItemIndex := 0;
ItemName := I;
if Supports(HtmlForm.item(ItemName, ItemIndex), IHTMLInputElement, InputElement) then
begin
if (InputElement.type_ = 'submit') and
(InputElement.value = '文本文件') then
begin
(InputElement as IHtmlElement).OnClick := OleVariant(Self as IDispatch);
break;
end;
end;
end;
end;
end;
end;
except
//
end;
end;