Disclosure Statement: This site contains affiliate links, which means that I may receive a commission if you make a purchase using these links. As an eBay Partner, I earn from qualifying purchases.
Opening new tab
-
- Posts: 112
- Joined: Wed Jul 01, 2020 10:22 am
Opening new tab
Is there a possibility to open links with target="_blank" in a new tab, not in a new window?
-
- Posts: 112
- Joined: Wed Jul 01, 2020 10:22 am
Re: Opening new tab
I tried to make 2 tabs with 2 ChromiumOSR browsers named Chromium1 and Chromium2 and type this
but application hangs.
Code: Select all
procedure TForm1.Chromium1BeforePopup(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
Header: ICefStringMultimap;
Request: ICefRequest;
Data: ICefPostData;
begin
showmessage('trying to open a new tab');
Result:=True;
Header := TCefStringMultimapOwn.Create;
Request := TCefRequestRef.New;
Header.Append('Referer', Frame.Url);
Request.Assign(targetUrl, '', nil, Header);
Chromium2.Browser.MainFrame.LoadRequest(Request);
ShowMessage('has opened');
end;
- salvadordf
- Posts: 4575
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: Opening new tab
Try cancelling the new popup window setting "result" to true, saving the targetUrl value and sending a windows message to the main form to use the targetUrl value as parameter in Chromium2.Load.
Remove the "showmessage" or any other function that creates, destroys or modifies VCL controls inside cef events because they are executed in a different thread and the VCL is not thread safe.
Please, consider using cef4delphi instead of dcef3. There're multiple demos and many bugs in chromium, cef and dcef3 were fixed.
Remove the "showmessage" or any other function that creates, destroys or modifies VCL controls inside cef events because they are executed in a different thread and the VCL is not thread safe.
Please, consider using cef4delphi instead of dcef3. There're multiple demos and many bugs in chromium, cef and dcef3 were fixed.
-
- Posts: 112
- Joined: Wed Jul 01, 2020 10:22 am
Re: Opening new tab
I have already done it (the code ^)Try cancelling the new popup window setting "result" to true
Thanks. It helps.Remove the "showmessage" or any other function that creates, destroys or modifies VCL controls inside cef events because they are executed in a different thread and the VCL is not thread safe.
My software is for windows xp. So I have to use old CEFPlease, consider using cef4delphi instead of dcef3. There're multiple demos and many bugs in chromium, cef and dcef3 were fixed.
-
- Posts: 112
- Joined: Wed Jul 01, 2020 10:22 am
Re: Opening new tab
I have found an answer!!!!!
It works PERFECT!!!
Code: Select all
procedure TForm1.Chromium1BeforePopup(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
Header: ICefStringMultimap;
Request: ICefRequest;
Data: ICefPostData;
begin
Result:=True;
Request := TCefRequestRef.New;
Request.Url := targetUrl;
Request.Method := 'POST';
Header := TCefStringMultimapOwn.Create;
Header.Append('Referer', Frame.Url);
Request.SetHeaderMap(Header);
Data := TCefPostDataRef.New;
Request.PostData := Data;
Chromium2.Browser.MainFrame.LoadRequest(Request);
chromium1.Browser.Host.SendFocusEvent(false);
chromium2.Browser.Host.SendFocusEvent(True);
end;
-
- Posts: 112
- Joined: Wed Jul 01, 2020 10:22 am
Re: Opening new tab
But sometimes it is a problem named APPCRASH in module libcef.dll 3.2454.1344.0 at 00186429. External exception 80000003.andreykrasnodar wrote: Sat Aug 08, 2020 10:03 am I have found an answer!!!!!
It works PERFECT!!!Code: Select all
procedure TForm1.Chromium1BeforePopup(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 Header: ICefStringMultimap; Request: ICefRequest; Data: ICefPostData; begin Result:=True; Request := TCefRequestRef.New; Request.Url := targetUrl; Request.Method := 'POST'; Header := TCefStringMultimapOwn.Create; Header.Append('Referer', Frame.Url); Request.SetHeaderMap(Header); Data := TCefPostDataRef.New; Request.PostData := Data; Chromium2.Browser.MainFrame.LoadRequest(Request); chromium1.Browser.Host.SendFocusEvent(false); chromium2.Browser.Host.SendFocusEvent(True); end;