I attached the event to the 'window' object, and I would like to test it there using code.
window.addEventListener('beforeunload', function(e){ /*...*/ }, false)
I tried simple and jQuery with no luck. I have more attempts on jsFiddle .
window.beforeunload //is undefined as is window.onbeforeunload $(window).data('events') //not working either
Is it possible?
There are similar questions ( here and here ) about the DOM and other elements, but none of the approaches in the ones I tried worked.
You can use the in ... operator
in
'onbeforeunload' in window; // true (if supported)
If supported, the property will exist, although the value will be null .
null
Source: https://habr.com/ru/post/1396319/More articles:How to remove symbolic links with phing? - windowsPHP + JQuery / AJAX - percent loader - jqueryIs there a way to create subclasses on the fly? - pythonIdeas for using the Hoeffding "D" GPU coefficient (dependency)? - statisticsIs there a way for Eclipse to launch its taskbar icon when a lot of time is up? - eclipseandroid get current location name - androidJava / Swing Volume Slider - javaUser Slider UI Swing - javaWork with Eclipse on two computers - eclipseArray rotation - javaAll Articles