I made a simple app that shows a MessageBox when a button is clicked.
After that Messagebox is shown, I navigate to another website at the same tab of browser , so if I click in the back button of browser the App reloads and show the same Messagebox waiting to be clicked, this means that Wisej app has stored this state and is consuming memory at the server even if I leave the page.
Is there a way to force Wisej app to exit when user leaves the web page and show a message to user that he is to loose data if leave the page?
Hi Joe,
it is not possible for Wisej and also for any other application which runs in a browser to determine when user closes the browser.
One way to show up a warning, when the user tries to leave the page is described here.
The problem in this solution is, that the unload event is also fired when the user refreshes the browser. And on server you cannot distinguish if the browser was closed or the user just hit F5.
But you can add for example a button to your app which will call Appliaction.Exit(), this will terminate the application and the corresponding session.
When the user leaves the page or closes the browser, Wisej will also terminate the App and the session after twice of SessionTimeout. SessionTimeout you can configure in Default.json.
Best,
Jens
Add this to Default.html. It will abandon the session when navigating, closing the tab, refreshing, hitting F5, or editing the URL. The alert behavior is different for different browser and some may or may not show the alert when refreshing. I think this is the wrong thing to do for a web application, but in Wisej you can do anything you’d like to do using standard browser functionality…
<script> window.addEventListener("beforeunload", function (e) { e.preventDefault(); e.returnValue = false; return "Are you sure?"; // this shows only in IE. }); window.addEventListener("unload", function (e) { Wisej.Core.exit(); Wisej.Core.removeSession(); }); </script>
Thank you Nic Adams, I’m sorry, that’s not what I want to know. I reformulated my question, please, could you answer again?
Hi Jeo,
If you mean what happens when a user closes their browser then eventually you should get the Application.Exit event fire if you want to do something specific, otherwise you can leave it to WiseJ to clean up the users session.
HTH
Nic
Please login first to submit.