Page 1 of 1

prevent new windows from opening when browsing

Posted: Sat May 04, 2024 3:52 pm
by ericktux
Hello friend, greetings and thank you for sharing, a question, how can I make all the searches open in the same window and thus prevent them from opening in new windows, I have tried several demos and the same thing happens.
please help

Re: prevent new windows from opening when browsing

Posted: Sat May 04, 2024 11:05 pm
by ericktux
Hello friends, at the moment this works:
in the event "NewWindowRequested" i put

Code: Select all

procedure TMiniBrowserFrm.WVBrowser1NewWindowRequested(Sender: TObject;
  const aWebView: ICoreWebView2;
  const aArgs: ICoreWebView2NewWindowRequestedEventArgs);
var
  TempArgs : TCoreWebView2NewWindowRequestedEventArgs;
begin
  // This demo blocks new windows
  TempArgs         := TCoreWebView2NewWindowRequestedEventArgs.Create(aArgs);
  //ShowMessage(TempArgs.URI);
  WVBrowser1.Navigate(TempArgs.URI); // open URL in the same window
  TempArgs.Handled := True;
  TempArgs.Free;
end;