procedure TForm2.WebBrowser1DocumentComplete(Sender: TObject;
const pDisp: IDispatch; var URL: OleVariant);
var
k:integer;
t:OleVariant;
begin
if (WebBrowser1.LocationURL='网页登录地址') then
begin
t := WebBrowser1.Document;
for k := 0 to t.all.length - 1 do
begin
if (uppercase(t.all.item(k).tagName)='INPUT')and (uppercase(t.all.item(k).Name)='用户名框 的name 名称') then
t.all.item(k).value:=editUserName.Text;
if (uppercase(t.all.item(k).tagName)='INPUT')and (uppercase(t.all.item(k).Name)='密码框的name 名称') then
t.all.item(k).value:=editPasswd.Text ;
if (uppercase(t.all.item(k).tagName)='INPUT')and (uppercase(t.all.item(k).Name)='登录按钮 的name 名称') then
begin
t.all.item(k).click;
break;
end;
end;
if (WebBrowser1.LocationURL='登录后转向的页面地址') then
showmessage('登录成功')
end;