用WEBBROWSER控件,如何用语句实现提交按钮呢?
如www.sohu.com,当用户名和密码框输入后,确定按钮是怎么实现的?

解决方案 »

  1.   

    直接生成一个Post请求,不需要WEBBROWSER
    不过使用WEBBROWSER的方法简单直观一点
      

  2.   

      var   
          i,j,ok:   integer;   
          doc:   olevariant;   
      begin   
          ok   :=   0;   
          doc   :=   web.document;   
          j:=doc.all.length;   
          for   i:=0   to   j-1   do   
          begin   
              if   (doc.all.item(i).tagname='INPUT')or   
                  (doc.all.item(i).tagname='TEXTAREA')   then   
              begin   
                  if   (doc.all.item(i).tagname='INPUT')and   
                      (doc.all.item(i).type='text')and   
                      (doc.all.item(i).name='phone')   then   //对方手机号   
                  begin   
                        inc(ok);     //=1   
                        doc.all.item(i).value   :=   sMobile.Strings[0];   
                  end;   
                  if(doc.all.item(i).tagname='TEXTAREA')and   
                    (doc.all.item(i).name='content')   then//内容   
                  begin   
                        inc(ok);     //=2   
                        doc.all.item(i).value   :=   sContent.Strings[0];   
                  end;   
                  if   (doc.all.item(i).tagname='INPUT')and   
                      (doc.all.item(i).type='text')and   
                      (doc.all.item(i).name='mycode')   then   //我的手机号   
                  begin   
                        inc(ok);//=3   
                        doc.all.item(i).value:='13601014304';   
                  end;   
                  if   (doc.all.item(i).tagname='INPUT')and   
                      (doc.all.item(i).type='password')   and   
                      (doc.all.item(i).name='mypw')   then   //密码   
                  begin   
                        inc(ok);   //=4   
                        doc.all.item(i).value:='bittime8262108';   
                  end;   
                  if   (doc.all.item(i).tagname='INPUT')and   
                      (doc.all.item(i).type='submit')and   
                      (doc.all.item(i).value='   发送   ')   then   //发送按钮   
                  begin   
                        inc(ok);//=5   
                        if   ok=7   then   
                            doc.all.item(i).click;   
                  end;   
              end;   
          end;   
      end;
    这是一个网站发送短信的代码,也许对你有用
      

  3.   

    procedure TForm1.Button7Click(Sender: TObject);
    var
      Docs, ovElements, form: OleVariant;
      wsName: widestring;
    begin  Docs := WebBrowser1.OleObject.Document;
      form := Docs.GetElementById('form1');
    // 直接调用 form 的 submit ,管它是按钮还是图片的
      form.submit;
    end;