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.
If you find these projects useful please consider becoming a sponsor with Patreon, GitHub or Liberapay.

Are their some ways to open new browser silently after JS click?

Post Reply
coater
Posts: 187
Joined: Sat Sep 29, 2018 1:51 pm

Are their some ways to open new browser silently after JS click?

Post by coater »

Are their some ways to open new browser silently after JS click?
Thank you!
User avatar
salvadordf
Posts: 4575
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Are their some ways to open new browser silently after JS click?

Post by salvadordf »

Is the TChromium.OnBeforePopup event triggered when you call the element.click() method?

If so, you can use the code in the MiniBrowser, PopupBrowser or PopupBrowser2 demos to show your new browser window.

MiniBrowser lets CEF handle all the window creation but you have to add multiple checks on many TChromium events to see which browser triggered each event.
coater
Posts: 187
Joined: Sat Sep 29, 2018 1:51 pm

Re: Are their some ways to open new browser silently after JS click?

Post by coater »

Yes, the TChromium.OnBeforePopup event was triggered.
The following is what I need:
The new window was open in background(not to be blocked), so the main form is still the active window.

WOD_NEW_BACKGROUND_TAB means what?
Thank you!
User avatar
salvadordf
Posts: 4575
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Are their some ways to open new browser silently after JS click?

Post by salvadordf »

coater wrote: Fri Jun 05, 2020 8:47 am Yes, the TChromium.OnBeforePopup event was triggered.
The following is what I need:
The new window was open in background(not to be blocked), so the main form is still the active window.
If you need total control of the new popup form then use the code in PopupBrowser2. Read the code comments in that demo to see why you need to create the new forms that way.
coater wrote: Fri Jun 05, 2020 8:47 am WOD_NEW_BACKGROUND_TAB means what?
This is all the information we have about the "Window open disposition (WOD)" contants :
https://bitbucket.org/chromiumembedded/ ... #lines-958

Code: Select all

///
// The manner in which a link click should be opened. These constants match
// their equivalents in Chromium's window_open_disposition.h and should not be
// renumbered.
///
typedef enum {
  WOD_UNKNOWN,
  WOD_CURRENT_TAB,
  WOD_SINGLETON_TAB,
  WOD_NEW_FOREGROUND_TAB,
  WOD_NEW_BACKGROUND_TAB,
  WOD_NEW_POPUP,
  WOD_NEW_WINDOW,
  WOD_SAVE_TO_DISK,
  WOD_OFF_THE_RECORD,
  WOD_IGNORE_ACTION
} cef_window_open_disposition_t;
If you open Chromium's window_open_disposition.h file you will see this :
https://chromium.googlesource.com/chrom ... position.h

Code: Select all

// DEPRECATED: Instead of introducing new references to this enum, use
// the generated ui::mojom::WindowOpenDisposition in
// ui/base/mojom/window_open_disposition.mojom.h.
enum class WindowOpenDisposition {
  UNKNOWN,
  CURRENT_TAB,
  // Indicates that only one tab with the url should exist in the same window.
  SINGLETON_TAB,
  NEW_FOREGROUND_TAB,
  NEW_BACKGROUND_TAB,
  NEW_POPUP,
  NEW_WINDOW,
  SAVE_TO_DISK,
  OFF_THE_RECORD,
  IGNORE_ACTION,
  // Activates an existing tab containing the url, rather than navigating.
  // This is similar to SINGLETON_TAB, but searches across all windows from
  // the current profile and anonymity (instead of just the current one);
  // closes the current tab on switching if the current tab was the NTP with
  // no session history; and behaves like CURRENT_TAB instead of
  // NEW_FOREGROUND_TAB when no existing tab is found.
  SWITCH_TO_TAB,
  // Update when adding a new disposition.
  MAX_VALUE = SWITCH_TO_TAB
};
The ui/base/mojom/window_open_disposition.mojom.h file that it's mentioned is this one :
https://chromium.googlesource.com/chrom ... tion.mojom

Code: Select all

// TODO(rockot/ben): This definitely seems like the wrong layer for a
// "window open disposition" concept. It's here to support existing uses of
// ui::WindowOpenDisposition.
//
// This maps to WindowOpenDisposition in //ui/base/window_open_disposition.h.
enum WindowOpenDisposition {
  UNKNOWN,
  CURRENT_TAB,
  // Indicates that only one tab with the url should exist in the same window.
  SINGLETON_TAB,
  NEW_FOREGROUND_TAB,
  NEW_BACKGROUND_TAB,
  NEW_POPUP,
  NEW_WINDOW,
  SAVE_TO_DISK,
  OFF_THE_RECORD,
  IGNORE_ACTION,
  // Activates an existing tab containing the url, rather than navigating.
  // This is similar to SINGLETON_TAB, but searches across all windows from
  // the current profile and anonymity (instead of just the current one);
  // closes the current tab on switching if the current tab was the NTP with
  // no session history; and behaves like CURRENT_TAB instead of
  // NEW_FOREGROUND_TAB when no existing tab is found.
  SWITCH_TO_TAB,
};
As you can see, we only have the details for 2 constants. For the rest, we have to guess the meaning from their names.
In the case of "WOD_NEW_BACKGROUND_TAB" I would say that the new browser should be in a new tab and it shouldn't be focused immediately.
coater
Posts: 187
Joined: Sat Sep 29, 2018 1:51 pm

Re: Are their some ways to open new browser silently after JS click?

Post by coater »

Thank you very much!
Post Reply