IHTMLFormElement.submit不执行onsubmit怎么搞?

解决方案 »

  1.   

    procedure TForm1.Button1Click(Sender: TObject);
    var
      Form:IHTMLFormElement;
      HTMLDocument2:IHTMLDocument2;
    begin
        HTMLDocument2 := WebBrowser1.document as IHTMLDocument2;
        if HTMLDocument2.forms.length > 0 then
        begin
          Form := (HTMLDocument2.forms as IHTMLElementCollection).item(0,0) as IHTMLFormElement ;
          (Form.item(0,0) as IHTMLInputTextElement).value := 'naughtyboy';
          (Form.item(1,0) as IHTMLInputTextElement).value := 'iamnaughtyboy';
           Form.Submit;
        end;end;
    换成上面样子看看,我刚刚试了试,能提交。
    另外最好能把你的代码贴出来
      

  2.   

    163邮箱登陆
    procedure TForm1.Button2Click(Sender: TObject);
    var
       o : Olevariant;
    begin
      webbrowser1.Navigate('http://www.163.com');
      o := WebBrowser1.OleObject.document.all.item('username',0);
      o.value := 'username';
      o := WebBrowser1.oleobject.document.all.item('Password',0);
      o.value := 'password';
      o :=WebBrowser1.oleobject.document.all.item('login',0);
      o.Click;
    end;
      

  3.   

    to naughtyboy(一切都是为了明天) ( )   确实可以提交,但是它不会触发页面中的Form OnSubmit事件
    to: linzhisong(無聊) ( )  我的表单是在页面的一个frame中,怎么做?
      

  4.   

    大致代码如下:procedure aaaaaaa;
    var
      Document: IHTMLDocument2;
      form: IHTMLFormElement;
      v: IHTMLInputElement;
      s: IHTMLButtonElement;
      frabase: IHTMLFrameBase2;
    begin
      w.Document.QueryInterface(IID_IHTMLDocument2, Document);
      //我现在搞不定怎么访问frame,就用了activeElement
      Document.activeElement.QueryInterface(IID_IHTMLFrameBase2, frabase);
      //获取frame,获取form
      frabase.contentWindow.document.all.item('form1',0).QueryInterface(IID_IHTMLFormElement, form);
      //获取v
      form.item('v',0).QueryInterface(IID_IHTMLInputElement, v);
      //获取send按钮
      form.item('s', 0).QueryInterface(IID_IHTMLButtonElement, s);
      //assign value
      v.value := '...';
      form.submit; //这样不会触发页面中的OnSubmit事件,我要怎么提交?
    end;
      

  5.   

    procedure TForm1.Button1Click(Sender: TObject); 
    var
      i: integer; 
    begin 
      for i := 0 to (WebBrowser1.OleObject.Document.frames.Length - 1) do 
        if WebBrowser1.OleObject.Document.frames.item(i).document.queryCommandEnabled('Copy') then 
          ShowMessage('copy command is enabled for frame no.' + IntToStr(i));
    end;
     试试这个吧。