Message when closing window
How to show alert message on ZEN when user closing window?
Standart js way to add listener is not working.
I tried this
ClientMethod onloadHandler() [ Language = javascript ] { zenPage.window.addEventListener('onbeforeunload', function(e){ return 'Are you sure you want to leave?'; }); }
and this, but both are unsuccessfully .
ClientMethod onloadHandler() [ Language = javascript ] { zenPage.window.onbeforeunload = zenPage.myClientMethod; }
Client Side Callback Methods for the Page
I don't know why, but it is not working for me.
Did you try this callback and it was working?
Yes, checked and it works in IE11 (see screenshot).
In addition, you can find in the file zenutils.js the following code:
Googling "onbeforeunload не работает" or "onbeforeunload javascript not working".
I found what is the problem.
When I have opened new window through zenPage.launchPopupWindow - it is not working ( method onunloadHandler()).
But when I have used zenPage.window.open, method onunloadHandler() works very well.
It also can be solved.
The behavior of zenPage.launchPopupWindow depends on the setting useSoftModal.
Play around with %OnUseSoftModals in the following example: