Jump to content

browser or tab close


jahlxx

Recommended Posts

Hi.

I need to prevent data lose when a user close the browser or the tab where de unigui app is running.

I'm trying some options.

One of them is in MainModule, the event OnBrowserClose. Tee event is detected, but don`t executes my code.

Any idea and / or help?

 

Thanks

Link to comment
Share on other sites

Well.

procedure TUniMainModule.UniGUIMainModuleBrowserClose(Sender: TObject);
begin
   if formdata.haycambios then
      //MessageDlg('Hello);
      MessageDlg('There are changes Do you want to update them ?', system.uitypes.TMsgDlgType.mtconfirmation, [system.uitypes.TMsgDlgBtn.mbYes, system.uitypes.TMsgDlgBtn.mbNo, system.uitypes.TMsgDlgBtn.mbCancel], formdata.update_data);
end;

 

Don't raises the dialog, and don`t executes the formdada.update_dada procedure

 

Thanks

Link to comment
Share on other sites

Ok.

Can I change UniMainModule.BackButtonAction in runtime? I could set by default to bbaDoNothing, and set to bbWarnUser if the user has done some changes .

If yes, how? And how can I change the default message?

With this, I almost have what I need.

Thanks.

 

Link to comment
Share on other sites

24 minutes ago, jahlxx said:

I only want to change the message text.

The default message that appears in the confirmation box, is different in different browsers. However, the standard message is something like "Are you sure you want to leave this page?". This message cannot be removed.

However, you can write a custom message together with the default message. See the first example on this page. 

Note: This only works in Internet Explorer.

https://www.w3schools.com/jsref/event_onbeforeunload.asp

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...