How to handle the event of the × button in the web browser
0
This is my first post. Thank you. Please review the following details and provide a solution. [What I Want to Achieve] I would like to execute a microflow when either the × button on the Mendix screen tab or the browser × button is pressed. [Method] I have placed an HTML Snippet on the initial screen during login. The content of the HTML Snippet is as follows: (Note: The same issue occurs even when using the pagehide event handler.) // Process when the page is unloaded window.addEventListener('unload', function(event) { if (event.returnValue === true) { // Microflow to be executed when the user clicks "OK" mx.data.action({ params: { applyto: "microflow", actionname: "MyFirstModule.ACT_Browser_Close"}, origin: this.mxform, callback: function(obj) { // Callback processing }, error: function(error) { console.error(error.message); }});}}); [Problem] When pressing the × button on the Mendix screen tab or the browser × button, the microflow works in my environment, but it rarely works in the customer's environment (though it does work sometimes).[Operating Environment] Both environments use Chrome with the same version. Additionally, both use the same APP (mpk file integration). Mendix versions are 9.18.0 or 10.12.4 (in upgrade). Perform in a local environment. [Other things I did] Even if I used the "Leave Trigger" in the MarketPlace, MicroFlow worked in my environment, but it didn't work in the customer's environment. Thank you in advance for your assistance.
asked
maezono yoshihiro
2 answers
0
Hi Maezono,
sometimes script executes when DOM is not fully loaded.
try once using code in settimout function of 2 sec suppose
let me know if it works or you need further assistance
answered
Sharad Suryavanshi
0
Hi Suryavanshi,
Thank you for your quick response. I'll give it a try!