I tried all possible ways to remove an event from window
object :
window.onbeforeunload = null;
window.BeforeUnloadEvent = null;
$(window).unbind('beforeunload');
$(window).off('onbeforeunload');
window.removeEventListener('beforeunload', carol, true);
window.removeEventListener('onbeforeunload', carol, true); // carol is that function see image below
and when i type getEventListener(window) is still present there
does anybody know another way or am i doing something wrong ?
The leading "on"
is only used when event listeners are accessed as object properties. When removing the event, just use the event name:
window.removeEventListener('beforeunload', carol, true);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.