I have a page with an unload listener, something very simple like:
$(window).on("beforeunload", function(e){
if (someCondition) return null;
});
After the load, if I click anywhere on the page then try to close my tab, I'll get a warning.
However, if I close the tab before any interaction with the DOM then I won't get the warning.
I put a breakpoint on the return null;
that shows that it is called but then ignored by the browser (Chrome 67.0.3396.99 on Mac OS 10.13.6).
Is there a reason for that? Any way around it?
Thanks in advance for your help :)