unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, OleCtrls, SHDocVw;
type
TForm1 = class(TForm)
WebBrowser1: TWebBrowser;
Button1: TButton;
WebBrowser2: TWebBrowser;
procedure Button1Click(Sender: TObject);
procedure WebBrowser1NewWindow2(ASender: TObject; var ppDisp: IDispatch;
var Cancel: WordBool);
procedure WebBrowser2BeforeNavigate2(ASender: TObject;
const pDisp: IDispatch; var URL, Flags, TargetFrameName, PostData,
Headers: OleVariant; var Cancel: WordBool);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
WebBrowser1.Navigate('http://www.baidu.com');
end;
procedure TForm1.WebBrowser1NewWindow2(ASender: TObject; var ppDisp: IDispatch;
var Cancel: WordBool);
begin
ppDisp := WebBrowser2.DefaultInterface;
Cancel := False;
end;
procedure TForm1.WebBrowser2BeforeNavigate2(ASender: TObject;
const pDisp: IDispatch; var URL, Flags, TargetFrameName, PostData,
Headers: OleVariant; var Cancel: WordBool);
begin
WebBrowser1.Navigate(URL);
Cancel := True;
end;
end.
TWebbrower禁止弹出窗口
原创mb643d15e043b20 博主文章分类:delphi ©著作权
文章标签 Public Windows 文章分类 JavaScript 前端开发