Window: beforeunload event in Mendix

0
Hi there!   It is possible to get the page close event on the client side (javascript). window.addEventListener('beforeunload', (event) => { // Cancel the event as stated by the standard. event.preventDefault(); // Chrome requires returnValue to be set. event.returnValue = ''; }); https://developer.mozilla.org/en-US/docs/Web/API/Window/beforeunload_event   I would like to do this with Mendix nanoflow, but don't know how. Could you please tell me how to do this?   Thanks! Iwata
asked
2 answers
0

Hi Sugura,

 

Probably the HTML/JavaScript Snippet widget can help you to run a JS (and register an event listener) during page loading. It is worth a shot!

 

Best,

Istvan

answered
0

Hi Suguru,

 

There is a close page Action that can be modelled in a Nanoflow (Client side). https://docs.mendix.com/refguide/nanoflows/

 

Adding an addEventListener is not possible.

 

You can create custom Javascript Actions: https://docs.mendix.com/howto/extensibility/write-javascript-actions/

You can interact with the Client API from these Javascript Actions: https://docs.mendix.com/howto/extensibility/write-javascript-actions/

 

Go Make It

answered