Page 1 of 1

Js closes the program.

Posted: Sun May 03, 2020 8:15 am
by dvbss11
Js closes the program.

The situation is
That when js calls window.close the form on which TCEFWindowParent hangs is trying to close. I don’t need it spoils the entire program system if I stop putting some variables in FormCloseQuery. As I understand it, this is just a post message that can be deleted and that’s it. Only where I do not know. in which module. I will track that this happens when TCEFWindowParent is deleted. farther Code stoped it doesn’t go and FormCloseQuery is called,
to me really need to find either this line in the modules or another solution without adding code to FormCloseQuery


This happens with window.close in other cases, everything works well.
I use before closing the browsers event through synchronization I delete Parent and as soon as it succeeds immediately for some reason FormCloseQuery is called

Re: Js closes the program.

Posted: Sun May 03, 2020 8:24 am
by salvadordf
Try using the TChromium.OnClose event and add this code line :

Code: Select all

aAction := cbaCancel; 

Re: Js closes the program.

Posted: Sun May 03, 2020 8:38 am
by dvbss11
does not help TCefCloseBrowserAction = (cbaClose, cbaDelay, cbaCancel); everyone calls FormCloseQuery

this form is not the main

Re: Js closes the program.

Posted: Tue May 05, 2020 9:32 am
by salvadordf
I modified the MiniBrowser demo with this code in the TChromium.OnClose event :

Code: Select all

procedure TMiniBrowserFrm.Chromium1Close(Sender: TObject; const browser: ICefBrowser; var aAction : TCefCloseBrowserAction);
begin
  if (browser <> nil) and (Chromium1.BrowserId = browser.Identifier) then
    begin
      PostMessage(Handle, CEF_DESTROY, 0, 0);
      aAction := cbaDelay;
    end
   else
    aAction := cbaCancel;
end;
Then I loaded this page to test the "window.close" call :
https://www.w3schools.com/jsref/tryit.a ... _win_close

I clicked the "Open myWindow" button to create a popup window and then I clicked the "Close myWindow".

The code in the TChromium.OnClose event sets aAction := cbaCancel; for the popup window and it remains open.

Setting the aAction parameter seems to work correctly. If you have a different situation please provide the code to reproduce this issue.