Page 1 of 1
Avoid JS dialogs
Posted: Wed Dec 19, 2018 1:06 pm
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
Re: Avoid JS dialogs
Posted: Wed Dec 19, 2018 1:52 pm
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.
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.
Re: Avoid JS dialogs
Posted: Wed Dec 19, 2018 3:07 pm
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.