Answer the question
In order to leave comments, you need to log in
Why does it crash from the application when performing OnBeforePopup on TChromium in Delphi?
Hello Lord! One more question:
I'm trying to prevent clicking on links with the creation of external windows in the browser, and implement them by opening them in the current page with the following code:
procedure TForm6.ChromeTabs1ButtonAddClick(Sender: TObject;
var Handled: Boolean);
var
T: TTabSheet;
web: TChromium;
begin
PageControl1.ActivePageIndex := ChromeTabs1.ActiveTabIndex;
T := TTabSheet.Create(self);
T.PageControl := PageControl1;
T.Caption := 'General';
PageControl1.ActivePage := T;
// t.TabVisible:=false;
web := TChromium.Create(T);
web := TChromium.Create(self);
TWinControl(web).Name := 'NewWebBrowser' + inttostr(random(999666111));
TWinControl(web).Parent := T;
web.Align := alClient;
web.Load('ya.ru');
web.OnBeforePopup := mybeforepopup;
end;
procedure Tform6.myBeforePopup(Sender: TObject; const browser: ICefBrowser;
const frame: ICefFrame; const targetUrl, targetFrameName: ustring;
targetDisposition: TCefWindowOpenDisposition; userGesture: Boolean;
var popupFeatures: TCefPopupFeatures; var windowInfo: TCefWindowInfo;
var client: ICefClient; var settings: TCefBrowserSettings;
var noJavascriptAccess: Boolean; out Result: Boolean);
var
web: TChromium;
begin
// prevent popup
web.Load(targetUrl);
Result := True;
end;
Answer the question
In order to leave comments, you need to log in
You seem to have an elementary confusion in the variables. Your created web browser: TChromium; is a local variable of the TForm6.ChromeTabs1ButtonAddClick procedure, not known outside of it. Inside Tform6.myBeforePopup, some other web variable is declared, which has nothing to do with the previous one, and is also used, as already written, without Create. Get it right and it will work.
I found out during tests that in the loaded page, after the dynamic creation of the Chromium component, the transition through the Yandex site to the Market, News, etc. tabs. available. When searching for other sats and following the search links, it gives this error.
I checked the same thing without dynamic creation, but directly through the component on the Chromium1 form, everything works, there are no errors
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question