现抄一段吧,当初我只做了这一部分就是在beforenavigate之前判断一下
要打开的newwindows的url,如果在黑名单中,则关闭这个东东,完整的例子
看我个人信息中的所提问题吧
procedure Tfrmhtmlbrowser.WebBrowserBeforeNavigate2(Sender: TObject;
const pDisp: IDispatch; var URL, Flags, TargetFrameName, PostData,
Headers: OleVariant; var Cancel: WordBool);
var
item: TdxBarButton;
newitemlink: TdxBarItemLink;
Tag: Integer;
begin
Tag := (Sender as TEmbeddedWB).Tag;
if EnableBacklist then
if BackList.IndexOf(url) <> -1 then
if ConfirmCloseBackList then
begin
if Application.MessageBox('是否关闭该黑名单窗口?', '关闭黑名单窗口', MB_ICONQUESTION + MB_YESNO) = idyes then
begin
//关闭该窗卡
Cancel := True;
closetag := Tag;
delwindowmenu(closeTag);
Timer_closepageex.Enabled := True;
end;
end
else
begin
Cancel := True;
closetag := Tag;
delwindowmenu(closeTag);
Timer_closepageex.Enabled := True;
end;
item := TdxBarButton.Create(Self);
item.Caption := url;
item.hint := url;
item.OnClick := gourl;
newitemlink := GotoUrl.itemlinks.Add;
newitemlink.Item := item;
if PageControl.ActivePage.Tag = Tag then
begin
URLs.Text := URL;
Statusbar.Panels[0].Text := URL;
end;
end; //end WebbrowserNavigate2