Submit的问题! ( 积分: 100 )

  • 主题发起人 主题发起人 Mclkings
  • 开始时间 开始时间
M

Mclkings

Unregistered / Unconfirmed
GUEST, unregistred user!
为什么Submit不管用!请指教!
-------------------------------相关测试代码如下!
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,mshtml, OleCtrls, SHDocVw, StdCtrls;

type
TForm1 = class(TForm)
Button1: TButton;
WebBrowser1: TWebBrowser;
procedure fdsf(Sender: TObject; const pDisp: IDispatch;
var URL: OleVariant);
procedure Button1Click(Sender: TObject);

private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.fdsf(Sender: TObject; const pDisp: IDispatch;
var URL: OleVariant);
var
hform:IHTMLFormelement;
hdoc:ihtmldocument2;
hall:ihtmlelementcollection;
Hinput:IHTMLinputelement;
iw:iwebbrowser2;
hlen,tmploop:integer;
vk:oleVariant;
dispatch:IDispatch;
booA,Boob:Boolean;
begin
if Assigned(webbrowser1) then
Begin
Booa:=False;
Boob:=False;
hdoc:=webbrowser1.document as ihtmldocument2;
hall:=hdoc.get_all;
hlen:=hall.get_length;
for tmploop:=0 to hlen-1 do
begin
vk:=tmploop;
dispatch:=hall.item(vk,0);
if succeeded(Dispatch.QueryInterface(IHTMLInputelement,hinput)) then
begin
if uppercase(hinput.Type_)='TEXT' then
Begin
hinput.value:='Mclkings';
Booa:=True;
End
else if uppercase(hinput.type_)='PASSWORD' then
Begin
hinput.value:='123456';
Boob:=True;
End;
end;
if succeeded(dispatch.QueryInterface(IHTMLFormElement,hform))and (uppercase(hform.name)='Login')Then
Begin
Hform.submit;
End;

End;
End;


end;

procedure TForm1.Button1Click(Sender: TObject);
begin
webbrowser1.Navigate('http://192.168.0.231/yto/yp/user_login.asp');
end;

end.
 
为什么Submit不管用!请指教!
-------------------------------相关测试代码如下!
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,mshtml, OleCtrls, SHDocVw, StdCtrls;

type
TForm1 = class(TForm)
Button1: TButton;
WebBrowser1: TWebBrowser;
procedure fdsf(Sender: TObject; const pDisp: IDispatch;
var URL: OleVariant);
procedure Button1Click(Sender: TObject);

private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.fdsf(Sender: TObject; const pDisp: IDispatch;
var URL: OleVariant);
var
hform:IHTMLFormelement;
hdoc:ihtmldocument2;
hall:ihtmlelementcollection;
Hinput:IHTMLinputelement;
iw:iwebbrowser2;
hlen,tmploop:integer;
vk:oleVariant;
dispatch:IDispatch;
booA,Boob:Boolean;
begin
if Assigned(webbrowser1) then
Begin
Booa:=False;
Boob:=False;
hdoc:=webbrowser1.document as ihtmldocument2;
hall:=hdoc.get_all;
hlen:=hall.get_length;
for tmploop:=0 to hlen-1 do
begin
vk:=tmploop;
dispatch:=hall.item(vk,0);
if succeeded(Dispatch.QueryInterface(IHTMLInputelement,hinput)) then
begin
if uppercase(hinput.Type_)='TEXT' then
Begin
hinput.value:='Mclkings';
Booa:=True;
End
else if uppercase(hinput.type_)='PASSWORD' then
Begin
hinput.value:='123456';
Boob:=True;
End;
end;
if succeeded(dispatch.QueryInterface(IHTMLFormElement,hform))and (uppercase(hform.name)='Login')Then
Begin
Hform.submit;
End;

End;
End;


end;

procedure TForm1.Button1Click(Sender: TObject);
begin
webbrowser1.Navigate('http://192.168.0.231/yto/yp/user_login.asp');
end;

end.
 
后退
顶部