M
M
M0OL0L2021-09-28 19:24:37
AJAX
M0OL0L, 2021-09-28 19:24:37

Why doesn't the load event fire on window?

Hello Connoisseurs! The question is why the load event in window. An example is here https://jsfiddle.net/Navaho/4krntxwj/1/ , lines 6 and 7 (click/scroll events) work like clockwork, but the load event freezes something! Did the same only on pure XMLHttpRequest all events (click & load & scroll) work like clockwork.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
nowm, 2021-09-28
@M0OL0L

The "load" event doesn't fire because this code is called after the page has loaded.

window.addEventListener('load',  event => f(event))

The page loaded and window.onload fired, and only then do you make a fetch that registers a listener for this event. Naturally, the event will not be caught.
By the way, it is not at all clear why you are trying to listen to it. You can do without it, because it has nothing to do with the end of the download using fetch.

G
galaxy, 2021-09-28
@galaxy

if( (event.type == 'scroll' && document.documentElement.clientHeight + document.documentElement.scrollTop == document.documentElement.offsetHeight)  || (event.type == 'click')  ){

where is something about load?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question