在WebBrowser中一个表单验证页面提交成功或失败后,都会JAVASCRIPT弹出成功或失败信息,我使用键盘事件却无法关闭这个JAVASCRIPT窗口,请问有什么好的方法可以自动关闭或屏蔽该JAVASCRIPT窗口呢?

解决方案 »

  1.   

    使用EmbeddedWb:
    http://www.euromind.com/iedelphi/embeddedwb.htm在它的OnShowMessage中屏蔽:
    http://www.euromind.com/iedelphi/embeddedwb/onshowmessage.htm
      

  2.   

    具体的实例就是:当Result是S_OK的时候,屏蔽所有的弹出窗口
    function TForm1.EmbeddedWB1ShowMessage(hwnd: Cardinal; lpstrText, lpstrCaption: PWideChar; dwType: Integer; lpstrHelpFile: PWideChar; dwHelpContext: Integer; var plResult: Integer): HRESULT;
    begin
      Result := S_OK; 
    end;
      

  3.   

    If Result:=S_OK all messages are disabled. Default is Result:=S_FALSE (show all messages). 
      

  4.   

    谢谢蓝天,可我在DELPHI7中用不起呢.
      

  5.   

    我试了这个控件,但不成功,代码如下,请高手指点:
    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, OleCtrls, SHDocVw, EmbeddedWB, StdCtrls;type
      TForm1 = class(TForm)
        EmbeddedWB1: TEmbeddedWB;
        Button1: TButton;
        function EmbeddedWB1ShowMessage(hwnd: Cardinal; lpstrText,
          lpstrCaption: PWideChar; dwType: Integer; lpstrHelpFile: PWideChar;
          dwHelpContext: Integer; var plResult: Integer): HRESULT;
        procedure Button1Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementation{$R *.dfm}function TForm1.EmbeddedWB1ShowMessage(hwnd: Cardinal; lpstrText,
      lpstrCaption: PWideChar; dwType: Integer; lpstrHelpFile: PWideChar;
      dwHelpContext: Integer; var plResult: Integer): HRESULT;
    var
    Text: string;
    Caption: PChar;
    begin
      Caption :='EmbeddedWB Messagebox';
      text := lpstrText;
      plResult:=Windows.MessageBox(hWnd, Pchar(text), Caption,   dwType);
      Result := S_OK;
    end;procedure TForm1.Button1Click(Sender: TObject);
    begin
      EmbeddedWB1.Go('www.sina.com.cn');
    end;end.