Invoke a client action when browser / tab closes

Hi.


So I have a timer and if the browser/tab closes, i need to save the time that is left.

Any suggestion?


I did this but is not working.

"window.addEventListener("beforeunload", function(event) {

    $actions.CreateTimesLeft($parameters.Time)

});"

I call this on render? 


Thank you


Hi Sara,


You should place it in the OnReady event.

Check the example below, where I write a message to the console when leaving the page.


Kind Regards,
João

ReactiveSandboxTestConsoleLogWhenLeavingPage.oml

Hi João,
Your post helped me very much.
Thanks man

Hi Sara ,
I hope this will be helpful to you. Please check attached OML File

Demo : https://rahuljain877.outsystemscloud.com/Test/

Regards
--RJ--

PopUp.oml

Hi Rahul. 

It Is something like this but i am confused. How do you call the script in the first Screen but the validation is done at the second screen?

You wan to use this on first screen also ?

Yes. I want to use only at one screen

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.