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.

Avoid JS dialogs

Post Reply
thefunkyjoint
Posts: 513
Joined: Thu Aug 10, 2017 12:40 pm

Avoid JS dialogs

Post by thefunkyjoint »

Hi,

In order to avoid the JS confirmation dialogs like the attached example, i'm using this code on OnJsdialog method :

Code: Select all

  suppressMessage := true;
  result := false;
But somehow it's not working ; actually when the JS dialog open , the OnJSDialog method is not being triggered.

Any hints ?

Thanks
You do not have the required permissions to view the files attached to this post.
User avatar
salvadordf
Posts: 4564
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Avoid JS dialogs

Post by salvadordf »

That seems to be the dialog from the JavaScript 'onbeforeunload' event.

To ignore that event when you close the browser use a TRUE parameter in the TChromium.CloseBrowser call.

Code: Select all

Chromium1.CloseBrowser(True);
That call is the first step in the "destruction sequence" and it will trigger the TChromium.OnClose event which should be used to destroy TCEFWindowParent in the main thread.
After that, TChromium.OnBeforeClose will be triggered and you will be able to destroy that browser safely.
thefunkyjoint
Posts: 513
Joined: Thu Aug 10, 2017 12:40 pm

Re: Avoid JS dialogs

Post by thefunkyjoint »

Hello,

Actually the message happens when i try to load a new page in certain sites ; i'm not closing the browser.

By the way, here is JS the code i'm using as workaround to fix ; i'm running this code right after the page is loaded :

window.onbeforeunload = null;window.moveTo(0,0);

This did the trick.
Post Reply