1、禁止Webbrowes新窗口打开页面,强制在当前页面打开
方法:放两个webbrowser控件,错码如下;
procedure TForm1.WebBrowser1NewWindow2(Sender: TObject; var PpDisp: IDispatch; var Cancel: WordBool); begin PpDisp := WebBrowser2.Application; end; procedure TForm1.WebBrowser2BeforeNavigate2(Sender: TObject; const PDisp: IDispatch; var URL, Flags, TargetFrameName, PostData, Headers: OleVariant; var Cancel: WordBool); var urlStr: string; begin urlStr := string(URL); WebBrowser1.Navigate(urlStr ); Cancel := True; end;
时间: 2024-10-10 16:40:38