[ADMINCTR-395] Exporting / downloading magnolia app content triggers "unload"-Event of page window Created: 31/May/23 Updated: 21/Jun/23 |
|
| Status: | Open |
| Project: | Admincentral |
| Component/s: | None |
| Affects Version/s: | 6.2.27 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major |
| Reporter: | Wolf Bubenik | Assignee: | Unassigned |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
Custom code:
|
||
| Issue Links: |
|
||||
| Template: | |||||
| Acceptance criteria: |
Empty
|
||||
| Date of First Response: | |||||
| Visible to: |
Joerg von Frantzius, Wolf Bubenik
|
||||
| Epic Link: | AuthorX Support | ||||
| Team: | |||||
| Description |
| Comments |
| Comment by Roman Kovařík [ 01/Jun/23 ] |
|
Hi wolf.bubenik,
Looks like this is a browser behaviour as described here:
https://stackoverflow.com/questions/56651887/vaadin-onbeforeunload-event There are some pointers how to workaround this from Leif from Vaadin.
Hope that helps Roman |
| Comment by wolf bubenik [ 01/Jun/23 ] |
|
Thanks a lot, @Roman. This helps understanding what is going on. As I see it, there is not much (nothing) you can do about it. What I want to achieve is to invalidate the magnolia session when the user closes the browser tab without logging out. Unluckily at least some browsers (Firefox) only trigger "beforeunload" in this situation, but not "unload". |
| Comment by wolf bubenik [ 01/Jun/23 ] |
|
Hi Roman, I googled a bit and found that it is a general problem to trigger some action like logout when closing the browser tab or browser.
The most promising solution I found (the one I understand See:
$(document).ready(function(){
var validNavigation = false;
// Attach the event keypress to exclude the F5 refresh (includes normal refresh)
$(document).bind('keypress', function(e) {
if (e.keyCode == 116){
validNavigation = true;
}
});
// Attach the event click for all links in the page
$("a").bind("click", function() {
validNavigation = true;
});
// Attach the event submit for all forms in the page
$("form").bind("submit", function() {
validNavigation = true;
});
// Attach the event click for all inputs in the page
$("input[type=submit]").bind("click", function() {
validNavigation = true;
});
window.onbeforeunload = function() {
if (!validNavigation) {
// -------> code comes here
}
};
});
Than we check this flag before doing the logout.
|